PyCharm 2017.3 Help

Keymap:

Extract Method

Basics

When the Extract Method refactoring is invoked, PyCharm analyses the selected block of code and detects variables that are the input for the selected code fragment and the variables that are output for it.

The detected output variable is used as a return value for the extracted function.