Tag: python

Comparing Version Numbers in Python

The distutils module is going to be deprecated in Python 3.10, and to be removed in Python 3.12. Hence, my current standard way of comparing version number strings is using pkg_resources module (part of setuptools): >>> from pkg_resources import parse_version as version >>> version(“1.0”) <Version(‘1.0’)> >>> version(“1.8.9”) < version(“2.0”) True >>> version(“2.0.9”) < version(“2.1”) True […]

Revisited: Version Numbering in Python Package

In Version Numbering in Python Package I showed a way to store the package version number in the code. The method is in hindsight not exactly the best one (who knew!), so here is another try for simple projects. Here I have mypackage/ (the package directory) mypackage/__init__.py mypackage/version.py setup.py with contents: mypackage/version.py: mypackage/__init__.py: setup.py: What […]

Python Loggers

This is a memo about my current standard way of logging in Python, especially when multiple modules are involved. In the main application (app.py): When app.py is started it gets the root logger in line 7. In main() it sets the logging configurations: logging level, formatter and handler. Here the handler is just outputting to […]