Rename refactorings allow to rename symbols, automatically correcting all references in the code.

The following rename refactorings are available in PyCharm:

Example 1

BeforeAfter
Renaming method
def  was_published_today(self):
      return  self.pub_date.date () == datetime.date.today()
     }
 
def  published_today(self):
        return  self.pub_date.date () == datetime.date.today()
    }

Example 2

Rename a template:

python_rename1

So doing, the following usages will be renamed:

python_rename2

  1. Select the item to be renamed.
  2. Choose Refactor | Rename on the main menu or on the context menu of the selection or press Shift+F6.
  3. The subsequent behavior depends on the check box Enable in-place mode (Settings | IDE Settings | Editor).
    • If this check box is selected, the suggested name appears right below the symbol in question. You can either accept suggestion, or type a new name. However, if you press Shift+F6 once more, PyCharm will display the Rename dialog box with more options.
    • If this check box is not selected, the Rename dialog box opens immediately.

    The set of controls and their names depend on the type of the symbol to be renamed.

  4. Preview and apply changes.

Local variables are renamed in-place:

python_rename_local

See Also

Reference:

Web Resources: