Skip to content

VersionWithSource#

VersionWithSource #

Bases: Version

Holds a version and the string it was created from. This is useful if you want to retain the original string the version was created from. This might be useful in cases where you have multiple strings that are represented by the same [Version] but you still want to be able to distinguish them.

The string 1.1 and 1.01 represent the same version. When you print the parsed version though it will come out as 1.1. You loose the original representation. This class stores the original source string, which can be accessed by source property.

This class derives from Version which allows you to compare it with other Version objects.

Comparison will be done based on the parsed version, not the source string.

__repr__() #

Returns a representation of the version

Examples#
>>> VersionWithSource("1.02.3")
VersionWithSource(version="1.2.3", source="1.02.3")
>>>

__str__() #

Returns the string representation of the version

Examples#
>>> str(VersionWithSource("1.02.3"))
'1.02.3'
>>>