9 reasons you should be using PyCharm

On my podcast, Talk Python To Me, I’m working on an episode highlighting PyCharm, the amazing IDE from JetBrains. Here’s a blog post to accompany that episode.

Update: Listen to the podcast interview with the PyCharm guys.

Many developers, especially in open source ecosystems such as Python and Ruby, or Linux-based web environments in general, tend towards the minimalist with regard to editors. This includes editors such as Emacs and VIM but I’d also throw in more UI based text editors such as Sublime Text, Notepad++, etc.

In some ways this makes perfect sense. If you spend a decent amount of time SSH’ed into Linux boxes in your data center, well GUI apps such as IDEs make little sense. If you’re doing open source, maybe you are looking for something non-commercial and free. Again, totally reasonable.

But the truth is, as professional developers, we spend most of our time on GUI-based OSes. Our time and effectiveness are extremely valuable.

Specifically for Python devs, I think we should be using the best tools that help us create but also read, test, maintain, and evolve the software we build. To me, the best software for this holistic purpose, is PyCharm. But often the conversation goes, “What feature makes using a big, heavyweight IDE that costs $200 worth it? I’ll just use Emacs” or something along those lines.

There probably isn’t a single reason that works for many people. Rather it’s the sum of all the features as a whole. Moreover, these only become a benefit once you take the time to truly learn them and leverage them without the features getting in the way.

So in this post, here are 9 of my favorite features of PyCharm which taken, in total, build a pretty serious case for giving PyCharm a chance. If your current workflow involves more pure text editors such as Emacs or Sublime Text, take a moment to see PyCharm with an open mind.

Finally, if you’re skeptical of this opinion and you think to yourself, “Here’s just another guy dependent on GUIs to write code. How weak. I don’t need that.” I should say that I spent several years writing C++ with Emacs on SGI supercomputers to great effect. So I have spent some time on both sides of the fence. For me, the grass is greener on this side.

Ok. Here they are: 9 reasons to consider making PyCharm your primary editor to write Python code. I could easily make this 25 but let’s start here.

1. Code completion

basic-intellisense.png

PyCharm has great code completion, whether it’s for a built-in or an external package.

I know I said it’s the sum total of features that make PyCharm worth it. Personally, I think great intellisense / code completion may be a single feature which alone wins me over. I have to deal with minor RSI issues and the amount of code I type vs the amount of code created by the tooling with good code completion really does make a big difference in both speed and health.

Python 3.5’s Type Hinting

pycharm-type-hints.png

If code completion fails you, type hints (as in episode_id: int ) will turn it right back on. Notice the dropdown lists methods from the int class.

Code completion for SQL and databases

sql-completiong-within-strings.png

Look carefully at the image above. That is a basic string literal but PyCharm has determined that it is likely a SQL expression so turns on syntax highlighting and code completion for language keywords (WHERE, FROM, etc).

Moreover, I have attached my SQLite DB to the project. PyCharm is suggesting database schema specific options! O. M. G. is what I thought when I first saw that. Because of the FROM Episodes, it knows that the SELECT clause should be columns from that table.

Just wow. Think of the time and effort as well as avoidance of bugs this will help you with.

SQLAlchemy in the debugger

sqlalchemy-to-sql-in-debugger-annotated.png

Set a breakpoint, pause in the debugger and you’ll see the SQL language representation of your SQLAlchemy ORM expression. Yeah, that’s amazing.

I think this is really just part of the string representation of SQLAlchemy ORM expression, but I don’t care because it’s so helpful!

Git visualization in the editor

inline-git-change-visualization.png

Wondering what is changed since the last time you did a git commit? Well that would be the blue sections right there! Can even get a diff of that segment or roll it back from within the editor.

Here’s the same file after I checked in the changes:

inline-git-change-visualization-after.png

Code coverage in the editor

code-coverage-in-editor.png

Yes, you can run coverage.py outside of PyCharm. But please click that image above and look around. The code coverage details are everywhere – in the project tree, in the summary, in the editor and more.

Now zoom in. See the greenish and redish parts in the margin? Those are the covered and not covered segments right in the editor!

code-coverage-in-editor-close.png

Package management

package-management.png

Yes, we can all use pip. But a nice visual representation of what’s installed, whether it’s current, and ability to search and add new packages is sweet.

Local history

local-history.png

I sure hope you’re using source control. But even if you are, local history is always keeping track of your changes in a way that complements things like Git. Need to roll something back even if it’s not part of a check in? Local history is always there.

Here’s a diff of a file where the changes between the two versions were not checked in.

local-history-diff.png

Refactoring

project-wide-refactoring.png

Last, but not least, the ability to make changes consistently and safely across 100’s of files by understanding the syntax tree (rather than text replace) is a primary reason to use an IDE in general and PyCharm in particular.

Conclusion

There you have it. Taken in total, those are some seriously powerful features. Check out PyCharm. They have free community editions, and the pro version is free for open source, students, and training.

Feel free to share your thoughts in the comments.

Thanks,
@mkennedy

18 comments

  • I love the features but its DOA for me.

    Why? I work in a Enterprise Windows 7 environment, and the user environments are on a server – so you can log in and work anywhere; roaming hot-desk stuff.

    There’s a size constraint on the User\local\roaming area on the server. Guess what? PyCham blows that, so I get many errors, can’t log out till I’ve tied it up by hand – and finally de-installed it. Game over.

    :(

  • You could also have code hinting with python < 3.5 whith the docstring you wrote within your classes, methods or functions.
    This single feature helped me to systematically write doc.

  • Just caught up with the podcast. Great job with the interview. One feature that was only superficially covered both in this article and the podcast is PyCharm’s database integration. While not a unique feature in and of itself, I always thought PyCharm’s implementation is both clean and powerful.

    Still a compelling list, thanks!

  • I’m pretty much sold on PyCharm, except… compared to Sublime, the syntax coloring seems very limited. For example, Sublime can distinguish between storage type (eg def, class) and other flow control (eg if, else, return) and builtin constants (eg True, False, None). Pycharm colors all these simply as keywords. For me, these are really useful distinctions to see in the code.

    Maybe there’s hidden customisation options that I haven’t stumbled over yet. Any insight from any Pycharm old timers would be appreciated.

  • Great article. I love PyCharm. One small error I saw. In the “Local History” section you wrote, “I sure hope you’re using source control. But even if you are,” I think you meant to write “But even if you aren’t,”

  • I really appreciate “ready_to_use_software” and the pay/to get stuff. BUT!

    For something like an editor that you will perhaps use for a veeeery long time you want to invest in learning the right tool. I was shocked when I started using emacs at how good it is (i am not foss or lisp zealot by the way). I have used textmate before but have not considered buying it. Primarily because I did not want to invest myself into “OSX only” editor. I did not like Sublime that much so that was off the table as well. On Windows I have always used Notepad++ or Sublime but since I have not been programming just doing a sysadmin I did not care that much either.
    Then I have invested the time and effort into learning emacs and was amazed by its capabilities. At first I was scared about how much time I will have to invest into learning / configuring the thing. But when looking back it was not that hard. A lot of people make amazing videos and share their configs. Amazing. Just by looking at few videos and browsing through some pre-made configs I was able to figure out the configuration I really want for my emacs. The rest I could just download from melpa and easily enable. Oh I almost forgot to point out how good emacs is at opening large files. It can handle it very well with vlf-mode.

  • PyCharm is awesome. But the problem is , as you mentioned in the beginning, too many of us are sshing to a remote desktop somewhere in cloud. I still haven’t found the setup that makes these kinds of great IDEs work reliably. I tried mounting the remote code via NFS, using local git repos… nothing work quite as efficient as good ol’ a properly set-up vim.

    • I’ve used UltraEdit for years specifically because of the ability to work with files directly on remote systems over FTP/SFTP. After hearing so many of Michael’s guests recommend PyCharm, I gave the trial a try and I’ve now moved almost exclusively to it. The EE also supports automatic deployment to SFTP hosts (I have auto deploy on save enabled) as well as remote interpreters so the autocomplete stuff still works.

  • I’m new to python and just started following your podcast. Create material and I agree that PyCharm is a wonderful IDE. Integration with the command line is a big benefit for productivity and speed.

  • jackbezalel

Submit a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s