class Version(_BaseVersion): (source)
This class abstracts handling of a project's versions. A :class:`Version` instance is comparison aware and can be compared and sorted using the standard Python interfaces. >>> v1 = Version("1.0a5") >>> v2 = Version("1.0") >>> v1 <Version('1.0a5')> >>> v2 <Version('1.0')> >>> v1 < v2 True >>> v1 == v2 False >>> v1 > v2 False >>> v1 >= v2 False >>> v1 <= v2 True
Method | __init__ |
Initialize a Version object. |
Method | __repr__ |
A representation of the Version that shows all internal state. |
Method | __str__ |
A string representation of the version that can be rounded-tripped. |
Property | base |
The "base version" of the version. |
Property | dev |
The development number of the version. |
Property | epoch |
The epoch of the version. |
Property | is |
Whether this version is a development release. |
Property | is |
Whether this version is a post-release. |
Property | is |
Whether this version is a pre-release. |
Property | local |
The local version segment of the version. |
Property | major |
The first item of :attr:`release` or ``0`` if unavailable. |
Property | micro |
The third item of :attr:`release` or ``0`` if unavailable. |
Property | minor |
The second item of :attr:`release` or ``0`` if unavailable. |
Property | post |
The post-release number of the version. |
Property | pre |
The pre-release segment of the version. |
Property | public |
The public portion of the version. |
Property | release |
The components of the "release" segment of the version. |
Class Variable | _regex |
Undocumented |
Instance Variable | _key |
Undocumented |
Instance Variable | _version |
Undocumented |
Inherited from _BaseVersion
:
Method | __eq__ |
Undocumented |
Method | __ge__ |
Undocumented |
Method | __gt__ |
Undocumented |
Method | __hash__ |
Undocumented |
Method | __le__ |
Undocumented |
Method | __lt__ |
Undocumented |
Method | __ne__ |
Undocumented |
Initialize a Version object. :param version: The string representation of a version which will be parsed and normalized before use. :raises InvalidVersion: If the ``version`` does not conform to PEP 440 in any way then this exception will be raised.
A representation of the Version that shows all internal state. >>> Version('1.0.0') <Version('1.0.0')>
A string representation of the version that can be rounded-tripped. >>> str(Version("1.0a5")) '1.0a5'
The "base version" of the version. >>> Version("1.2.3").base_version '1.2.3' >>> Version("1.2.3+abc").base_version '1.2.3' >>> Version("1!1.2.3+abc.dev1").base_version '1!1.2.3' The "base version" is the public version of the project without any pre or post release markers.
The development number of the version. >>> print(Version("1.2.3").dev) None >>> Version("1.2.3.dev1").dev 1
Whether this version is a development release. >>> Version("1.2.3").is_devrelease False >>> Version("1.2.3.dev1").is_devrelease True
Whether this version is a post-release. >>> Version("1.2.3").is_postrelease False >>> Version("1.2.3.post1").is_postrelease True
Whether this version is a pre-release. >>> Version("1.2.3").is_prerelease False >>> Version("1.2.3a1").is_prerelease True >>> Version("1.2.3b1").is_prerelease True >>> Version("1.2.3rc1").is_prerelease True >>> Version("1.2.3dev1").is_prerelease True
The local version segment of the version. >>> print(Version("1.2.3").local) None >>> Version("1.2.3+abc").local 'abc'
The third item of :attr:`release` or ``0`` if unavailable. >>> Version("1.2.3").micro 3 >>> Version("1").micro 0
The second item of :attr:`release` or ``0`` if unavailable. >>> Version("1.2.3").minor 2 >>> Version("1").minor 0
The post-release number of the version. >>> print(Version("1.2.3").post) None >>> Version("1.2.3.post1").post 1
The pre-release segment of the version. >>> print(Version("1.2.3").pre) None >>> Version("1.2.3a1").pre ('a', 1) >>> Version("1.2.3b1").pre ('b', 1) >>> Version("1.2.3rc1").pre ('rc', 1)
The public portion of the version. >>> Version("1.2.3").public '1.2.3' >>> Version("1.2.3+abc").public '1.2.3' >>> Version("1.2.3+abc.dev1").public '1.2.3'