Detect the minimum Python version to run code

In case we want to check if our code is compatible with a specific version of Python, we can get help from the library vermin.

Vermin is a library that detects the minimum Python version to run code.

As the documentation says:

“It functions by parsing Python code into an abstract syntax tree (AST), which it traverses and matches against internal dictionaries with 184 rules divided into 40 modules, 123 classes/functions/constants members of modules, and 21 kwargs of functions. Including looking for v2/v3 print expr and print(expr), "..".format(..), imports (import X, from X import Y, from X import *), and function calls wrt. name and kwargs.”

Here you can find some usage examples, which come from the github repo:

% ./vermin
Vermin 0.2.2
Usage: ./vermin [options] <python source files and folders..>

Options:
  -q      Quite mode. It only prints the final versions verdict.
  -v..    Verbosity level 1 to 2. -v shows less than -vv but more than no verbosity.
  -i      Ignore incompatible version warnings.
  -p=X    Use X concurrent processes to analyze files (defaults to all cores = 8).
  -d      Dump AST node visits.

% ./vermin -q vermin.py
Minimum required versions: 2.7, 3.0

% ./vermin.py -v examples
Detecting python files..
Analyzing 6 files using 8 processes..
             /path/to/examples/formatv2.py
2.7, 3.2     /path/to/examples/argparse.py
2.7, 3.0     /path/to/examples/formatv3.py
2.0, 3.0     /path/to/examples/printv3.py
!2, 3.4      /path/to/examples/abc.py
             /path/to/examples/unknown.py
Minimum required versions: !2, 3.4

When it yields !2 or !3 it means that it explicitly cannot run on that version

Handy tools: Notational Velocity

Sometimes we just want to take notes for our future selves, as a reference, and finding a good place to store this notes can be a hassle.

Suppose you need to keep at hand an internal url to access a resource on your company, or a set of operations that you seldom use in your programming language, or connection settings for a database…

The question is: Where do you normally store this?

Sticky notes, password managers, word or excel documents, databases… There’s advantages and drawbacks to all of them, but perhaps the trickiest deal is how to successfully search through this notes when we have a big amount of them, without compromising speed on creating new ones

Notational Velocity is a tool that provides a compromise between flexibility for adding new notes and speed for searching results. It’s damn fast.

The interface is simple. A search field on top, a list of results, and in the bottom half, the content of the note we select

To create a new note, we just keep adding the text we want as a title, and then press Enter to edit the body. Easy peasy.

notational-velocity-1

Personally I find it useful when I need to check quickly some alembic commands, or for internal urls to different servers, frequent errors that I receive on Python, docker config files, even some personal notes about software development best practises.

Notational Velocity is available for Mac Os X, there is also a siamese application  for Windows called Notation.

There is as well an updated – beta -version of Notational Velocity, called nvALT, which can be obtained here

 

[Notational Velocity]