dict.keys() ?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Jan 26 22:04:08 EST 2007


The PEP 3100:
http://www.python.org/dev/peps/pep-3100/
says:

Return iterators instead of lists where appropriate for atomic type
methods (e.g. dict.keys(), dict.values(), dict.items(), etc.); iter*
methods will be removed. Better: make keys(), etc. return views ala
Java collections???
...
To be removed:
   dict.setdefault()? [15]
   dict.has_key() method [done]


I may be sleepy now, but maybe the keys() method too can be removed;
otherwise the following two become really the same:

print list(adict)
for k in adict: ...

print list(adict.keys())
for k in adict.keys(): ...

Bye,
bearophile




More information about the Python-list mailing list