Pyenv Install and Select Multiple (global) Python Versions

In some scenarios you might have two (or more) different pieces of code in your source repository that may require different versions of Python to run. Like say 2.7 and 3.7 or 3.9 and 3.10. How can we make that happen with pyenv? To make multiple Python versions available at the same time in your […]

Profiling Python Flask Web Apps with Pyinstrument

In the previous post, I talked about using cProfile (via Werkzeug Application Profiler Middleware) to profile parts of code or routes in Flask web apps. In this one, we’ll explore another tool called pyinstrument that does statistical profiling instead of deterministic profiling, that can be easily used with Flask or any other web framework like […]

Pytest Print or Dump Variables to Console for Debugging

Trying to print(var) in your pytest tests and wondering why you cannot see the output in your terminal’s standard output? This is because by default pytest captures all output sent to stdout and stderr, i.e., it intercepts the data going into the low-level file descriptors 1 and 2. This is a good idea because pytest […]