Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
MASTERING PYCHARM

You're reading from   MASTERING PYCHARM Use PyCharm with fluid efficiency to write idiomatic python code

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783551316
Length 232 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Nafiul Islam Nafiul Islam
Author Profile Icon Nafiul Islam
Nafiul Islam
Arrow right icon
View More author details
Toc

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images