[Python-ideas] Add support for version objects

Serhiy Storchaka storchaka at gmail.com
Fri May 27 15:04:34 EDT 2016


I propose to add support for version objects in the stdlib. Version 
object is a namedtuple-like object with special attrbutes major, minor, 
etc for representing semantic version in the form used by most open 
source (and not only) software. The sys module already contains two 
version objects: sys.version_info and the result of sys.getwindowsversion().

There is a support of version objects in Perl [1] and .NET [2]. There 
are third-party Python implementations ([3], [4], [5]).

Version objects can be used for representing:

1. Version of Python itself (sys.version_info).
2. Version of OS and system libraries.
3. Static and runtime versions of wrapped libraries (zlib, expat, 
sqlite, curses, Tcl/Tk, libffi, libmpdec).
4. Versions of third-party modules.

The benefit of version objects against plain strings is that version 
objects are comparable with expected rules (1.2.3 < 1.10.1).

The benefit of version objects against tuples is human readable string 
representation and named attributes for components.

[1] http://search.cpan.org/perldoc?version
[2] 
https://msdn.microsoft.com/en-us/library/system.version%28v=vs.110%29.aspx
[3] https://pypi.python.org/pypi/semantic_version
[4] https://pypi.python.org/pypi/versions
[3] https://pypi.python.org/pypi/version
https://pypi.python.org/pypi/SemVerPy



More information about the Python-ideas mailing list