O'Reilly logo

Mastering Vim by Ruslan Osipov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reordering function arguments

Another common refactoring operation is to change the function arguments. Let's look at reordering arguments, since findings from this example can also be applied to other situations.

Here is a sample method in animal.py:

def act(self, target, verb):    return 'Suddenly {kind} {verb} at {target}!'.format(            kind=self.kind,            verb=verb,            target=target)

The order of arguments in this method doesn't seem very intuitive. We might be better off changing it to look like this:

def act(self, verb, target):    return 'Suddenly {kind} {verb} at {target}!'.format(            kind=self.kind,            verb=verb,            target=target)

However, there are quite a few callers for this method already, since we also use the method in farm.py (the code is intentionally ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required