Steve Holden wrote:
> Question: what's the difference between
>
> dict((name, seq) for seq, name in enumerate(description))
>
> (the improved version of my answer posted by Scott David Daniels) and
>
> dict(enumerate(description))
a missing
def enumerate(x, enumerate=enumerate): # ov
George Sakkis wrote:
> "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 enume
James Stroud wrote:
> On Friday 14 October 2005 08:37, Steve Holden wrote:
>> >>> dct = dict((x[1], x[0]) for x in enumerate(description))
To make the code a breath more obvious:
>>> dct = dict((name, seq) for seq, name in enumerate(description))
has the same results.
>> >>> dct
>>
>>{'second': 1
"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))
> > >>> d
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}
>
> regards
>
Echo wrote:
> Hello,
> Here is what I am trying to do. I am trying to make a dict that has a
> key that is the value an element in a list and the value for the dict to
> be the index.
> This is the closest I have been able to get:
> dict((d[0],i) for d in self.cu.description for i in
> xrange(l