Skip to main content

accepts 2 version string as input and returns whether one is greater than, equal, or less than the other

Project description

This is a software library that accepts 2 version string as input and returns whether one is greater than, equal, or less than the other. As an example: "1.2" is greater than "1.1".



from compare_string_version import compareVersion

expected return



    a is equal to b


    a is greater than b


    a is less than b


either a is null and/or b is null: Value(s) can not be null: Both values must be string
either a and/or b are/is not a string: Both must be string


a and b are string

a and b are not null (None)

both version strings only contain numbers (0...9) and this char '.':


    'A..Z','a..z' and any other chars like "! @ # $ % * [ } ] { ^ ç ? ; : . > , < | " will be removed from the comparison:
        some adjustment would be applied after char removal:
        '..' will be replaced by '.'
        string ending in '.' will be shorted by 1

this '..' will not be accepted as it is '.' duplicated:
        '10..12..13..14' will become ''

the comparison would be from the group split by the char '.': would be treated as 10 12 13 14 would be treated as 1 10 100 1

all the comparison would check the integer part of the version:
        '10.0' is equal to '' because int('10.0') is equal to int ('010')

whoever version number has the higher far left group would be named as greater: is greater then is greater than 0.0.9
        the same "int" rule will be applied for any other group in the string

all '0's from the left will be disregarded if its value is '0': is equal to 1.0 and it is equal to 1

the following .py were used in order to test data has generated output5.txt has generated output4.txt has generated output1.txt and output2.txt has generated output3.txt

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for compare-string-version, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size compare_string_version-0.1.0-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size compare_string_version-0.1.0.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page