A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-April/134192.html below:

[Python-Dev] PEP 469: Restoring the iterkeys/values/items() methods

[Python-Dev] PEP 469: Restoring the iterkeys/values/items() methodsStephen J. Turnbull stephen at xemacs.org
Sat Apr 19 18:30:20 CEST 2014
Guido van Rossum writes:

 > Does everyone involved know that "for x in d.iterkeys()" is
 > equivalent to "for x in d" and works the same in Python 2 and 3? 
[...]

 > This doesn't solve itervalues() and iteritems() but I expect those
 > are less common, and "for x, y in d.iteritems(): <blah>" is
 > rewritten nicely as
 >
 >   for x in d:
 >     y = d[x]
 >    <blah>

I suppose there's no way to get the compiler to both make "for x in d"
work as above, and make "for k, v in d" be equivalent to Python 2's
"for k, v in d.iteritems()"?  It seems totally analogous to getting
both "for x in list" and "for x, y in list_of_couples" to DTRT.  (To
me, anyway.)

You'd still be stuck on itervalues(), but at least you'd have the
option of "for _, v in d" (ie, the usual idiom for a value you're
going to ignore) without creating a list.




More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4