Constructor via hexΒΆ

Hex strings are accepted in the constructor.

Example: Constructor including hex strings.

from verr import Version

v = Version(1, 2, 3, "0xffbbff0b")
print(v.major_revision == int("ffbb", 16)) # True
print(v.minor_revision == int("ff0b", 16)) # True
print(v) # 1.2.3.4290510603
print(v.to_str(3)) # 1.2.3
print(v.to_tuple()) # (1, 2, 3, 4290510603)
print(v.to_tuple(3)) # (1, 2, 3)
print(v.elements) # 4

v = Version('0xd', '0x02', '0x001a', '0XAB')
print(v)  # 13.2.26.171

Hex strings are required to be prefixed with 0x.

Tip

Hex strings are not case sensitive.

Attention

Malformed strings are converted as integers as well.

If a string has non-alphnumeric characters then the non-alphnumeric characters are stripped away.

from verr import Version

v = Version.parse('10.1')
print(v) # 10.1

v = Version.parse('10_000.(%2/1)')
print(v) # 10000.21

v = Version.parse('0xab12.0x_1c2d]')
print(v) # 43794.7213

v = Version.parse('"12_^.0x_1c2d]')
# dec 12
# hex 0x1c2d
print(v) # 12.7213

See Also: Version class