The Rename refactoring lets you change names of symbols, files and all the references to them throughout code.
Renaming local variables or private methods can be done easily inline since only the limited scope is affected. Renaming classes or public methods could potentially impact a lot of files. Preview potential changes before you refactor.
In the editor, select an element you want to rename. If you need to rename a file or a directory, select one in the Project tool window.
Press Shift+F6 or from the main menu, select.
You can perform a rename refactoring in-place or press Shift+F6 again to open the Rename dialog if you need to specify additional options. For example, specify where to search for element occurrences, or what else to rename. You can also specify a scope for the refactoring.
Click Preview to see the potential changes and click Refactor.
Next time you invoke the Rename refactoring, PyCharm remembers the options you have specified inside the Rename dialog.
Let's rename a method:
import datetime def was_published_today(self): return self.pub_date.date () == datetime.date.today()
import datetime def published_today(self): return self.pub_date.date () == datetime.date.today()