"James Stroud" <[EMAIL PROTECTED]> wrote:
> Could be even simpler since enumerate creates tuples anyway:
>
> dct = dict(x for x in enumerate(description))
>
> James
>
> On Friday 14 October 2005 08:37, Steve Holden wrote:
> > >>> dct = dict((x[1], x[0]) for x in enumerate(description))
> > >>> dct
> >
> > {'second': 1, 'third': 2, 'first': 0}
"James Stroud" wrote
> Could be even simpler since enumerate creates tuples anyway:
>
> dct = dict(x for x in enumerate(description))
>
> James
>
> On Friday 14 October 2005 08:37, Steve Holden wrote:
> > >>> dct = dict((x[1], x[0]) for x in enumerate(description))
> > >>> dct
> >
> > {'second': 1, 'third': 2, 'first': 0}
Or even simplest :-)
dct = dict(enumerate(description))
George
--
http://mail.python.org/mailman/listinfo/python-list