Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character sequences and integer numbers, like > this: > > > 'si_pos_99_rep_1_0.ita' -> ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita')
>>> parts = re.compile("([+-]?\d+)").split('si_pos_99_rep_1_0.ita') >>> parts[1::2] = map(int, parts[1::2]) >>> parts ['si_pos_', 99, '_rep_', 1, '_', 0, '.ita'] Peter -- http://mail.python.org/mailman/listinfo/python-list