def convert_to_decimal(string):
    """
    Decode the exif-gps format into a decimal point.
    '[51, 4, 1234/34]'  ->  51.074948366
    """
    number_or_fraction = '(?:\d{1,2}) | (?:\d{1,10} \\ \d{1,10})'
    m = re.compile('''\[?\s?            # opening bracket
                    \d{{1,2}}\s?,\s?    # first number
                    {0} \s?,\s?         # second number (can be a fraction)
                    {0} \s?,\s?         # third number (can be a fraction)
                    \]?\s?              # closing bracket
                    '''.format(number_or_fraction), re.VERBOSE)
    if not m.match(string):
        raise ValueError

    h, m, s = re.sub('\[|\]', '', string).split(', ')
    result = int(h)
    if '/' in m:
        m = m.split('/')
        result += int(m[0]) * 1.0 / int(m[1]) / 60
    else:
        result += int(m) * 1.0 / 60
    if '/' in s:
        s = s.split('/')
        result += int(s[0]) * 1.0 / int(s[1]) / 3600
    else:
        result += int(s) * 1.0 / 60
    return result
def convert_to_decimal ( string ) : number_or_fraction = '(?:\d{1,2}) | (?:\d{1,10} \\ \d{1,10})' m = re . compile ( '''\[?\s?            # opening bracket
                    \d{{1,2}}\s?,\s?    # first number
                    {0} \s?,\s?         # second number (can be a fraction)
                    {0} \s?,\s?         # third number (can be a fraction)
                    \]?\s?              # closing bracket
                    ''' . format ( number_or_fraction ) , re . VERBOSE ) if not m . match ( string ) : raise ValueError h , m , s = re . sub ( '\[|\]' , '' , string ) . split ( ', ' ) result = int ( h ) if '/' in m : m = m . split ( '/' ) result += int ( m [ 0 ] ) * 1.0 / int ( m [ 1 ] ) / 60 else : result += int ( m ) * 1.0 / 60 if '/' in s : s = s . split ( '/' ) result += int ( s [ 0 ] ) * 1.0 / int ( s [ 1 ] ) / 3600 else : result += int ( s ) * 1.0 / 60 return result
Decode the exif-gps format into a decimal point.
    '[51, 4, 1234/34]'  ->  51.074948366