In this article I would like to describe few tools I’m using everyday to be efficient Python programmer. There is multiple approaches how efficiently control your programming environment but I have converged to this set of tools. I’m looking from any tool that I’m using at work to be

  • easy to learn i.e. having shortcuts always somewhere visible.
  • controlable by shortcut that can be carved in my muscle memory.
  • capable of fast perfomance tasks I’m doing quite often.

So when we have my criteria stated let’s go to see what’s worth using and learning.

IDE

To code Python I was originally using Vim with ton of plugins (see me .vimrc). However vim with many plugins fails with my first criterion of efficient tool: I could not remember all the shortcuts for the most plugins so I end using only few features of the plugin. Plus my setup was getting really slow sometimes. Hard to say why this happened. Also I wasn’t very happy with code discovery options I had so I started to looking for something else.

Obvious choice was and is now more than ever: PyCharm. It is really fast, memory manageable and helpful tool that allows me to have the best picture about code I have in front of me. But one thing I took from my experience with vim: I cannot write code without it anymore. Luckily there is quite good plugin ideavim. IdeaVim brings vim text controlling to PyCharm so I can use the best of both worlds: IDE part from PyCharm and vim for typing. Below I write some shortcuts that I’m using most in PyCharm:

Shortcut Explanation
Alt + F7 Find usages of symbol under cursor - great for knowing every place where e.g. function is called with no false positives
Ctrl + b/click Go to declaration - allows to go even to third party that can be temporarily changed
Ctrl + Shift + o Reopen project - this is my own. Since I’m working easily on 10 projects per day it is necessary to reopen the project
Ctrl + Shift + n Jump to file - allow great guessing what file you need
Ctrl + Alt + n Inline variable - when variable is not needed replace its usage by its definition
Ctrl + Alt + m Extract sequence of expressions to method with dealing of arguments and return types

I know that there is a lot more things that PyCharm can offer but those actions are my most used. I like to explore code of libraries I’m using and PyCharm is quite helpful in this.

Command line

Second place where I dwell most of the time is the command line. I like to use git, pytest and IPython from command line because I think it is faster than clickable options in PyCharm (even with using shortcuts). My terminal emulator of choice is Terminator because it allows me to use sane tab-change shortcut (ctrl-tab instead of ctrl-pgup), easily split the panels and have infinite buffer for lines.

As a shel I chose Zsh with great plugin manager Oh-my-Zsh. Oh-my-zsh is nice and it has a lot of nice features built-in (autocompletion) and also great selection of prompts (jreese for me). There I’m using quite good git plugin for autocompletion and aliases, autojump that allows to easily cd between projects without need to write proper path and the lifesaver zsh-autosuggestions. Zsh-autosuggestions automatically searches through bash history as would Ctrl-r do but this will print the found command in greyed font after what I’m writing. I can easily use the history or rewrite some argument. This really helps with proper commands format and also searching in long forgotten commands that are used only once in a year. I also like to write my own aliases and function for often used commands (e.g. convert timestamp to readable date - date -d @1267619929 becomes ts 1267619929 and I no longer have to think about what argument should be there.

As I have a lot of projects in Python and need to take care of dependencies I’m using virtualenvwrapper to sandbox my working environments. It that has few nice features on top virtualenv (I rather call workon env than source .env/bin/activate). But when there is a lot of projects and I switch between them it can become nuisance to constantly change virtualenv. Luckily there already is package that solves this: autovenv. It looks at requirements.txt file in folder and when it is there it activate env that is named after that directory. When you jump out it will deactivate. Simple but powerfull and it allows me not to worry about env I’m using: it’s always the right one.

The set of tools constantly evolves as I’m learning more about them. It’s kind of my hobby so I’m glad to hear every new tool that can be helpful for my work.