[Tutor] better way to write this code
eryksun
eryksun at gmail.com
Fri Aug 24 14:36:07 CEST 2012
On Fri, Aug 24, 2012 at 8:11 AM, Peter Otten <__peter__ at web.de> wrote:
>
> for index, name, fixer in fixers:
> item = event[index]
@Norman
I forgot to mention this. You should index the event instead of
iterating over it. I suppose each event has a name in index 12, so you
shouldn't get an IndexError.
Then you can loop over combos:
for index, name in combos.items():
event_dict[name] = event[index]
Or you can generalize the process as Peter has shown.
More information about the Tutor
mailing list