def parse_scale ( x ) : match = re . match ( r'^(.+?):(\d+)$' , x ) if not match : raise ValueError ( 'Invalid scale "%s".' % x ) return match . group ( 1 ) , int ( match . group ( 2 ) )
how to read a scale as a number python
Splits a %s : %d string and returns the string and number .
def parse_scale(x):
    """Splits a "%s:%d" string and returns the string and number.

    :return: A ``(string, int)`` pair extracted from ``x``.

    :raise ValueError: the string ``x`` does not respect the input format.
    """
    match = re.match(r'^(.+?):(\d+)$', x)
    if not match:
        raise ValueError('Invalid scale "%s".' % x)
    return match.group(1), int(match.group(2))