Why is dictionary.keys() a list and not a set?

bonono at gmail.com bonono at gmail.com
Thu Nov 24 01:23:17 EST 2005


Steve Holden wrote:
> bonono at gmail.com wrote:
> > jep... at unpythonic.net wrote:
> > [...]
> >>Maybe there are also other reasons to promise this property that I'm not
> >>aware of.  Certainly it seems like this property is useful and not hard
> >>to provide for "non-perverse" implementations, much like the
> >
> > Thanks, but we don't need the list comprehension(or do we) ? As the
> > return of d.iteritems() is already a list of tuples.
> >
> No it isn't: it's a dictionary item iterator. This can be used to
> provide a list, but it's self-evidently an iterator, not a list:
Oops, typo. I was meant to say d.items(). stand corrected.




More information about the Python-list mailing list