In which I actually use the editor to write code
Previously, I attempted to write up my experiences with the new beta of the PyCharm editor for Python, from JetBrains, makers of IntelliJ IDEA. By the time I got a basic installation working and started a Django project, I ran out of time. This time around, I actually wrote a little bit of code using PyCharm, so I have a few more things to say.
Things I like
It defaults to spaces, not tabs. This is correct.
Ctrl-space does menu completion, and this works very well. If you’re used to Intellisense, this does what you expect. Any IDE worth its salt should be able to accomplish this basic task.
Overriding methods get a little icon in the left gutter that takes you to the source code for the methods they override, and similarly, overridden methods allow you to navigate up and down the hierarchy. This is neat, and not something I’ve seen any Python editor do before.
The Structure panel is great. It updates as you code, and uses icons to distinguish between variables, functions, and methods.
You can duplicate a line with Ctrl+D, comment a line with Ctrl+/, and indent/dedent a line with Tab/Shift-Tab. If there is an active selection, these commands work on the selection instead. These are super-handy and very intuitive features.
Entire blocks can be easily rearranged by the Move Statement Up / Move Statement Down (Ctrl+Shift+Up/Down) commands. This seems like it would be really handy for code reorganization.
Ctrl+B will jump to the definition of the symbol under the cursor, and if it’s ambiguous it pops up a menu where you can pick which definition you mean. Likewise, Ctrl+N lets you type a class name to jump to, searches as you type, and lets you refine your choice with a pop-up menu. I can see this being a huge time saver.
The basic refactorings are all there: Rename, Change Signature, Move, Copy, Safe Delete, Inline, Pull Up, Push Down, Extract Interface, Extract Superclass. I’m not sure what Extract Interface does, since Python doesn’t really have interfaces (third-party implementations aside), but Extract Superclass has a nice interface where you can check which methods you want to move into the new base class. If the current class already extends a class, it will use multiple inheritance. This isn’t Java!
Out of the box, PyCharm supports CVS, Subversion, Git, and Mercurial. Not too shabby!
Editor windows can be split horizontally and vertically, and each split pane can have its own tabs. The tabs don’t currently support drag’n'drop, which is a bummer, but I bet they’ll have that working soon, since everyone expects that to work with web browsers nowadays.
Things I’m on the fence about
The real-time syntax checking is slightly distracting, just as I recall it being with IDEA. As I type, various things get underlined with red squigglies to notify me that my syntax is invalid. It’s invalid, usually, because I haven’t finished typing yet.
Code folding works great, if you’re into that sort of thing. I seem to be the odd one out – I can’t stand it. It just creates a bunch of noise, and I feel like if your program is so big and deeply nested that you need to collapse sections of it, you should fix your program. But anyway, PyCharm does folding just fine.
Things I don’t like
Introspection doesn’t always work too well. When I tried to create a models.CharField for a model, it popped up with the hint that CharField takes the arguments (self, *args, **kwargs). I’m sure there’s some fancy footwork going on in Django that makes this difficult, but it would be really helpful to have argument hints about basic stuff like this if PyCharm is to claim any sort of Django support.
One of the more amazing refactorings that IDEA can do, which I think is called Replace Inheritance With Delegation, is not available in PyCharm. I think this is a great tool, and hopefully it will get integrated with PyCharm someday. Python’s support for multiple inheritance makes it less necessary, perhaps (since the big benefit with Java is to be able to pick a different base class without breaking anything, since Java only allows single-inheritance).
By default, you can click anywhere and it will put the cursor at that point, even if it’s 50 characters to the right of the text. This really bothers me, but fortunately it’s easy to disable: File->Settings->IDE Settings->Editor->Virtual Space->Allow placement of caret after end of line.
PyCharm follows the convention that many Windows-style programs do these days, where Ctrl-Left/Right moves between words but Alt-Up/Down moves between paragraphs. I don’t know who came up with this, but I really prefer Ctrl-Up/Down for symmetry, and so that I can keep Ctrl held down and easily move around. Ctrl-Up/Down works like a mouse wheel, which is a nice feature but I wish it had a different shortcut. Alt-Left/Right switches between tabs, which is handy but also weird to me. But I’m really nitpicking here.
Indexing takes a long time. After opening the editor, you’ll want to grab some coffee or what-have-you.
This is really just a superficial evaluation of PyCharm, since I would have to use it for much longer to really critique it properly. It appears to be well-implemented, full-featured, and artfully designed. I think I could be happy using PyCharm. I don’t know if it’s compelling enough to break my Emacs addiction, but it’s certainly a worthy contender. I recommend giving it a try!