Skip to content Skip to sidebar Skip to footer

Refactor With Pycharm From "user" To "self.user"

I want to move a variable from local scope to object level. The new code should use self.user and not user like before: class Foo(object): def test_foo(self): user=User

Solution 1:

What you are trying to do is not a simple rename, but creating a new instance attribute. As such, instead of using Rename you should use Extract > Field menu item. Alternatively you can access this refactoring as Ctrl+Alt+F (this depends on the shortcuts you have chosen. Mine is the default for KDE).


Post a Comment for "Refactor With Pycharm From "user" To "self.user""