#NEWLINE# def split_number_and_unit( s ) : #NEWLINE# #INDENT# 'Parse a string that consists of a integer number and an optional unit.\n    @param s a non-empty string that starts with an int and is followed by some letters\n    @return a triple of the number (as int) and the unit\n    ' #NEWLINE# if ( not pos ) : #NEWLINE# #INDENT# raise ValueError ( 'empty value' ) #NEWLINE# #UNINDENT# s = s . strip ( ) #NEWLINE# pos = len ( s ) #NEWLINE# while ( pos and ( not s [ ( pos - 1 ) ] . isdigit ( ) ) ) : #NEWLINE# #INDENT# pos -= 1 #NEWLINE# #UNINDENT# number = int ( s [ : pos ] ) #NEWLINE# unit = s [ pos : ] . strip ( ) #NEWLINE# return ( number , unit )