PyCharm
 
Get PyCharm
You are viewing the documentation for an earlier version of PyCharm.

Extract/Introduce variable

Last modified: 11 February 2024

If you come across an expression that is hard to understand or it is duplicated in several places throughout your code, the Extract Variable refactoring CtrlAlt0V can help you deal with those problems placing the result of such expression or its part into a separate variable that is less complex and easier to understand. Plus, it reduces the code duplication.

You can use the Introduce Variable refactoring to extract variadic arguments into a new slice variable.

If the In modal dialogs refactoring option is selected in the Refactorings area on the Code Editing page of the Settings dialog (CtrlAlt0S) , PyCharm opens the Extract Variable dialog for this refactoring.