On Wed, Apr 14, 2021 at 7:48 AM Christopher Barker <python...@gmail.com> wrote: > So what do you'all think? After thirteen years, it would be nice to put this > to bed.
There are two main use cases for versions: * Display them to the user * Compare versions to check if one is newer, older or the same I dislike using strings for comparison. You need to use packaging.version for that: https://packaging.pypa.io/en/latest/version.html Many C libraries provide the version as a number of as 3 numbers (major, minor, micro). In its C API, Python provides all of them: * PY_VERSION_HEX: single number * (PY_MAJOR_VERSION, PY_MINOR_VERSION, PY_MICRO_VERSION, PY_RELEASE_LEVEL, PY_RELEASE_SERIAL): as 5 numbers * PY_VERSION: string In my Python projects, I like to provide the version as a tuple which can be used directly for comparison: version_a <= version_b. Example: VERSION = (2, 2, 1) __version__ = '.'.join(map(str, VERSION)) The tuple might contain strings like "beta" or "rc", as soon as comparison makes sense ;-) Sadly, such tuple is no standardized. Which part is the major version? How to format it as a string? Good luck with trying to standardize that ;-) Victor -- Night gathers, and now my watch begins. It shall not end until my death. _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/MBBYB5AWX76O3TOUFATRKSU2QND2TPKS/ Code of Conduct: http://python.org/psf/codeofconduct/