It is common for Python modules to export their version number in list or tuple form. While it is simple to convert a dot-delimited string to a tuple, it's subtle and tricky to go the other way, particularly when you don't know how many "digits" there are. This recipe includes a pair of functions that convert between forms. Also handy for IP addresses!
1 2 3 4 5
def StringVersion( seq ): return '.'.join( ['%s'] * len( seq )) % tuple( seq ) def TupleVersion( str ): return map( int, str.split( '.' ))