versions

NamedTuple-like class to represent a version number.

New in version 0.4.4.

Classes:

Version([major, minor, patch])

NamedTuple-like class to represent a version number.

namedtuple Version(major=0, minor=0, patch=0)[source]

Bases: Tuple[int, int, int]

NamedTuple-like class to represent a version number.

Fields
  1.  major (int) – The major version number.

  2.  minor (int) – The minor version number.

  3.  patch (int) – The patch version number.

Changed in version 1.4.0: Implemented the same interface as a collections.namedtuple().

__eq__(other)[source]

Returns whether this version is equal to the other version.

Return type

bool

__final__ = True

Type:    bool

__float__()[source]

Return the major and minor version number as a float.

Return type

float

__ge__(other)[source]

Returns whether this version is greater than or equal to the other version.

Return type

bool

__gt__(other)[source]

Returns whether this version is greater than the other version.

Return type

bool

__int__()[source]

Return the major version number as an integer.

Return type

int

__le__(other)[source]

Returns whether this version is less than or equal to the other version.

Return type

bool

__lt__(other)[source]

Returns whether this version is less than the other version.

Return type

bool

__repr__()[source]

Return the representation of the version.

Return type

str

__slots__ = ()

Type:    tuple

__str__()[source]

Return version as a string.

Return type

str

_asdict()[source]

Return a new dict which maps field names to their corresponding values.

New in version 1.4.0.

Return type

Dict[str, int]

_field_defaults = {'major': 0, 'minor': 0, 'patch': 0}

Type:    Dict[str, int]

Dictionary mapping field names to default values.

New in version 1.4.0.

_fields = ('major', 'minor', 'patch')

Type:    Tuple[str, str, str]

Tuple of strings listing the field names.

Useful for introspection and for creating new named tuple types from existing named tuples.

New in version 1.4.0.

classmethod _make(iterable)[source]

Class method that makes a new instance from an existing sequence or iterable.

New in version 1.4.0.

Parameters

iterable (Iterable[Union[str, int]])

Return type

~_V

_replace(**kwargs)[source]

Return a new instance of the named tuple replacing specified fields with new values.

New in version 1.4.0.

Parameters

kwargs

Return type

~_V

classmethod from_float(version_float)[source]

Create a Version from a float.

Parameters

version_float (float) – The version number.

Return type

~_V

Returns

The created Version.

classmethod from_str(version_string)[source]

Create a Version from a str.

Parameters

version_string (str) – The version number.

Return type

~_V

Returns

The created Version.

classmethod from_tuple(version_tuple)[source]

Create a Version from a tuple.

Parameters

version_tuple (Tuple[Union[int, str], …]) – The version number.

Return type

~_V

Returns

The created Version.

Changed in version 0.9.0: Tuples with more than three elements are truncated. Previously a TypeError was raised.