def select_features_by_expression(self, layer):
     self._current_layer = layer
     self.iface.setActiveLayer(layer)
     dlg_expression_selection = QgsExpressionSelectionDialog(layer)
     layer.selectionChanged.connect(self.check_selected_features)
     dlg_expression_selection.exec()
     layer.selectionChanged.disconnect(self.check_selected_features)
 def select_feature_by_expression(self):
     Dlg_expression_selection = QgsExpressionSelectionDialog(
         self._current_layer)
     self._current_layer.selectionChanged.connect(
         self.check_selected_features)
     Dlg_expression_selection.exec()
     self._current_layer.selectionChanged.disconnect(
         self.check_selected_features)
# coding: utf-8
from qgis.gui import QgsExpressionSelectionDialog
from qgis.utils import iface

layer = iface.activeLayer()
expression_selection_dialog = QgsExpressionSelectionDialog(layer, '"whatever"')

expression_selection_dialog.show()