[Tutor] better way to write this code
Norman Khine
norman at khine.net
Fri Aug 24 17:02:50 CEST 2012
thank you for the detailed replies, i will try to update the code and post
it when done
On Fri, Aug 24, 2012 at 1:36 PM, eryksun <eryksun at gmail.com> wrote:
> 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.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for
c in ",adym,*)&uzq^zqf" ] )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120824/442dc5a0/attachment.html>
More information about the Tutor
mailing list