Skip to the content.

What Python version is that?!

Defensive coding

To ensure a script runs with a minimal version requirement of the Python interpreter one can use an assertion. More levels (micro, releaselevel, etc) can be added to the tuple, if necessary.

assert sys.version_info >= (2, 5)

Examples

— Oliver Frolovs, 2020