Book Image

Mastering PyCharm

By : Nafiul Islam
Book Image

Mastering PyCharm

By: Nafiul Islam

Overview of this book

Table of Contents (18 chapters)
Mastering PyCharm
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 another window that gives us a few options:

Here, [1] is very useful if we have put docstrings into the functions that describe variables. [2] will search for text documents such as .rst and .md. This already shows you how far PyCharm can...