def parse_bytes(field):
    '''
    >>> parse_bytes('24B')
    24.0
    >>> parse_bytes('4MiB')
    4194304.0
    '''
    if field[-1] in 'bB':
        field = field[:-1]

    try:
        for i, prefix in enumerate('KMGTPEZ'):
            if field.endswith(prefix + 'i'):
                factor = 2 ** (10 * (i + 1))
                return float(field[:-2]) * factor

        return float(field)
    except ValueError:
        return None
def parse_bytes ( field ) : if field [ - 1 ] in 'bB' : field = field [ : - 1 ] try : for i , prefix in enumerate ( 'KMGTPEZ' ) : if field . endswith ( prefix + 'i' ) : factor = 2 ** ( 10 * ( i + 1 ) ) return float ( field [ : - 2 ] ) * factor return float ( field ) except ValueError : return None
>>> parse_bytes('24B')
    24.0
    >>> parse_bytes('4MiB')
    4194304.0