So say I have a retrieved directory name, “LibX_00.03”, and I retrieve the version information of the directory with:
lib = "LibX_00.03"
version = lib[-5:]
After doing this I then want to compare this version number with others to assert the latest release of the library, the trouble with this being that is has to be in a numberic form for comparison and not a str.
Casting to int or float both do not work, as int will give a whole number, and float gives an innacurate conversion:
>>> float(version)
0.299999...
So how can I accurately preserve the version number while having it in a form where I make a comparison?
Note this won’t work if you have
'1.0b'as version string, for that useLooseVersion: