PyCharm is an IDE developed by JetBrains since 2010. Yes, the same company that developed IntelliJ, the de-facto default for Java. It costs $200 per year which is pretty expensive if you just get your feet wet with Python. It’s pretty cheap if you consider that the editor/IDE is one of the most important tools of a professional software developer.
It takes roughly 9 seconds on my ThinkPad T490s to start. Sublime Text takes less than a second. PyCharm also has this annoying “do you really want to close me” pop-up. When you close it, it automatically saves the document — but the edit history will be gone. This means you cannot to
Ctrl+Z to undo edits.
When you create a new file, you have to decide first which type it has, which name it has, and where it should be stored. In Sublime Text, you just start typing.
The User Interface
In the screenshot above you can see how PyCharm typically looks for me. As PyCharm allows quite a bit of customization, you have to say it like this. Let’s go through the components of the UI:
- The editor dominates the view. It supports syntax highlighting, shows the line numbers in the gutter, and the scroll bar indicates where it found warnings (yellow) and errors (red).
- To the left of the editor, there is a file explorer.
- To the right of the editor, there are two minimized elements that are pretty cool: A database explorer and the SciView. We will come to those later.
- In the footer, there are also minimized elements. I like the problems and the terminal section.
Find Action allows you to search for any menu. No more searching in deeply nested menus. It is similar to the Command Palette in Sublime Text.
If you have the Sublime Text key bindings, you can open the dialogue with
Ctrl+Shift+P . It looks like this:
In contrast to Sublime Text, PyCharm does not do a fuzzy search here.
Key bindings: Customizable Shortcuts!
If you go to File → Settings (
Ctrl+Alt+S ) and then to Keymap, you can select the defaults of other editors like Sublime Text. This makes a switch pretty easy. You also have a nice interface to set key bindings.
You can close a tab with
Ctrl+W , create a new file with
Ctrl+N , select the previous/next tab with
Ctrl+Page Down /
Ctrl+Page up . I haven’t found a way to jump to the first/second/n-th tab.
Jump to Line
Ctrl+G lets you go to a line. You can even specify the column you want to go to!
Ctrl+P lets you go to any file in the workspace. No fuzzy search, though 😢
Find / Replace All
Ctrl+F to find something,
Ctrl+H to replace. You can also use RegEx! Definitely a feature I don’t want to miss. This is pretty cool in combination with multiple cursors!
Distraction-Free Mode and Zen Mode
Shift+F11 switches in distraction-free mode. You just see the code. No mini-map, no file explorer, no footer. This is helpful if you want to show another developer something. The Zen mode is even better 😃
The autocompletion of PyCharm works well. PyCharm obviously makes use of type annotations 🎉
PyCharm also gives you hints when you create a new class or use a function:
Jump to Definition
F12 shows you the usage of the symbol under your cursor and brings you to the declaration of classes, methods, and functions. In contrast to Sublime Text, this works flawlessly in PyCharm.
PyCharm comes with a proper debugger. Have a look at the following image:
You can set a breakpoint at the line you’re interested in by clicking next to it (1). Then you click on the “debug” icon (2). PyCharm opens a variable explorer (3). Now you can decide if you want to step over / step into / step into my code / step out (4). It’s simple to use, but extremely valuable if you don’t have a clue what is going on.
PyCharm comes has a Marketplace that offers 2354 plugins. For Python, I like Rainbow Brackets: If you have multiple brackets after each other, it becomes hard to read them. Rainbow brackets colors the matching brackets to support you.
Please let me know if you have any other plugin you use for Python!
Cool rules I’ve noticed are:
- Spell checking: This works astonishingly well. Preventing typos is helpful because you don’t want to force downstream users to have to add typos e.g. if your function name was wrong.
- Documentation: PyCharm can check your docstrings against the function signature. This is pretty amazing 😻
In my example repository mpu I had a couple of those. This is a repository where I try hard to follow good practices.
The database tool window is a part of PyCharm where I don’t know yet what to think about it. One the one hand, it is useful. On the other hand, I like the Unix philosophy:
Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new “features”.
There are a couple of programs which fulfil the same purpose:
- phpMyAdmin: For MySQL / MariaDB only
- SQLite Browser: For SQLite only
- Heidi SQL: MySQL, MariaDB, PostgreSQL, SQLite, Microsoft SQL Server
- DBeaver: All databases which have a JDBC or ODBC driver, including MySQL, PostgreSQL, SQLite
- Jetbrains DataGrip: Pretty much the same as the plugin, I suspect?
The Scientific View is essentially trying to offer the capabilities of a Jupyter Notebook within PyCharm.
More details can be found here:
42 more hints
PyCharm can do a lot. Way more than I can show you in this 6 minute article. Give the following video a try:
Comparison: Community Edition and Sublime Text
PyCharms community edition editor is pretty crappy. Don’t even give it a try.
In comparison to Sublime Text, one has to mention the big price difference. You can use Sublime Text pretty well for free. Even if you are super annoyed by the reminder to pay for it, it still is only $70 once for Sublime Text compared to $200 per year for PyCharm.
Sublime Text offers what you need in 90% of your development time. In those cases, it is faster and less cluttered. However, especially the missing debugger might be a deal-breaker for you.
PyCharm Professional is an amazing IDE for professional Python developers. I love that they have nice autocompletion, can jump to definitions, and have a working spell-checker integrated. The debugger is also sometimes super helpful.
On the downside, PyCharms interface is too cluttered. To me, the editor has too little screen space. The context menus are just crazy huge and the starting time is too long if you just want to edit a small file.
In this “Python for Beginners” series, we already explained how to use Python with WSL2 on Windows, how to use Python on Windows with Anaconda. The editor Sublime Text was introduced as a good minimal starting point.
This article briefly introduced PyCharm Professional. In a follow-up articles, you will see Visual Studio Code. Stay tuned!