Writing code

This section has been purposely kept short and only showcases three powerful features that many PyCharm users are not completely aware of. The first two features are very simple and require us to simply use a keyboard shortcut, while the other feature requires a little more work.

Refactoring

Refactoring is one of PyCharm's most powerful features and its capabilities go beyond a single file. One of the simplest ways to see this feature at work is renaming a variable or a function:

def add_one(n):
    return n + 1


def foo(func, n):
    return func(n)


foo(add_one, 2)

In the preceding example, we want to change the function name foo to apply (because it makes more sense). This is of course a simple example, but helps prove a point.

This brings up ...

Get Mastering PyCharm now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.