PyCharm 2021.1 Help

Extract Field Dialog

Extract a field using the dialog

If the In modal dialogs refactoring option is selected in the Refactorings area on the Code Editing page of the Settings/Preferences dialog Ctrl+Alt+S, the Extract Field refactoring is performed by means of the Extract Field Dialog.

Enable inplace refactoring cleared
  1. In the editor, select the expression or variable to be replaced with a field, or just position the caret within such an expression or variable declaration.

  2. In the main menu, or the context menu of the selection, choose Refactor | Extract | Field, or press Ctrl+Alt+F.

  3. From the Expressions list, select the expression to be replaced. Note that PyCharm highlights the selected expression in the editor.

  4. In the dialog that opens, specify the type and name of the new field.

  5. In the Initialize in section, specify where the new field will be initialized.

  6. To automatically replace all occurrences of the selected expression (if it is found more than once), select the option Replace all occurrences.

  7. Click OK to create the field.

Last modified: 08 March 2021