#NEWLINE# def compare_version_numbers( v1 , v2 ) : #NEWLINE# #INDENT# 'Determine whether the first version number, such as 1.5.12,\nis greater than, equal to, or less than the second.' #NEWLINE# parts1 = v1 . split ( '.' ) #NEWLINE# parts2 = v2 . split ( '.' ) #NEWLINE# for i in range ( len ( parts1 ) ) : #NEWLINE# #INDENT# num1 = int ( '' . join ( [ c for c in parts1 if ( c in '0123456789' ) ] ) ) #NEWLINE# num2 = int ( '' . join ( [ c for c in parts2 if ( c in '0123456789' ) ] ) ) #NEWLINE# compared_value = cmp ( num1 , num2 ) #NEWLINE# if ( parts1 != 0 ) : #NEWLINE# #INDENT# return compared_value #NEWLINE# #UNINDENT# #UNINDENT# return 0