I have been writing Python code professionally at Uniregistry for over five years now. It has also been my primary language for projects and algorithm challenges since early in University (2008).
At Uniregistry, we use a custom web framework based on Pyramid
and SQLAlchemy
. It doesn't come with Django
's vast package/app ecosystem, but SQLAlchemy is a very powerful ORM, and I enjoy the query syntax & fine-grained control we have over relationship loading.
I've also recently created a small Django REST Framework
service using Python
3.7 and am loving the improvements. (Type annotations are excellent inline documentation, and I was happy to discover that dictionaries and sets now maintain the order of insertion.)
I first started using Python
in my second year of university when I taught myself Python
& Django
for a team project. I chose Django
for the excellent documentation, and it taught me a lot about building complete server-side web stacks. Django
's source code is also an excellent introduction to Web Application Security / OWASP Top Ten.
I also used Django
in 2010 when I worked for a startup. I replaced much PHP with simpler Python
code and used Django
to spin up a pretty admin interface with more custom functionality than phpMyAdmin.
I pick up a lot of new tools/ideas from the following podcasts.
The following are my favourite tools I've been collecting over the last couple of years. These bullet points might turn into blog posts someday.
IPython
I've been using IPython
for a while to test things in a REPL quickly. It's excellent at autocompleting everything on the PYTHONPATH
and a fantastic way to explore docs.
I've also customised our Pyramid
shell to provide shortcuts to our DAOs and all commonly used backend tasks/manager objects, making it an incredibly powerful production OPS shell. (Careful here: "with great power, etc." 😉)
sentry
We host a private instance of https://sentry.io's error monitoring system, and I've written the code to annotate exceptions/errors with user information and additional information about the originating web route/backend task. It saves us all hours of debugging work every week.
Jupyter
notebooks
I've used Jupyter
notebooks when they were still IPython
notebooks to document some parts of our code base for myself at work. Recently I've used them even more heavily when I took the deeplearning.ai course. I'm still learning the ins and outs of pandas
and Matplotlib
, but I'm a big fan of their notebook integration.
devpi-server
If you install many packages or need to experiment with many different virtualenvs running devpi-server
on localhost
saves incredible amounts of time and data. (Looking at you pipenv lock
😒)
pytest
Our test suite currently contains ~8000 unit/integration tests, which massively increases our confidence in each deployment. Tips:
pytest --durations
discovers the slowest tests. Sometimes you can massively speed up everyone's test runs by fixing a couple of outliers.pytest-testmon
is incredible if you can get it to work reliably. It reverses test coverage to find all tests that could be influenced by changed code and runs only the relevant subset of the suite.pipsi
or pipx
Python finally has an npx
equivalent to simplify installing Python tools in separate virtualenvs (to avoid conflicting dependencies).
asdf
asdf
acts as a universal "tool version manager", much like pyenv
/nvm
/countless others. I first used it to switch Elixir
versions; now it's also my primary tool to manage Python versions.
I'd love to learn about more Tips & Tricks in Python-land. If you feel like I'm missing something super obvious or just want to chat Python, please feel free to contact me.