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

Stephen J. Turnbull turnbull at sk.tsukuba.ac.jp
Sat Apr 19 19:31:34 CEST 2014


Benjamin Peterson writes:

 > > 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()"?

 > That doesn't make sense. What if your keys are tuples?

Oh, I still think it makes sense.  Both x and k would be bound to the
key tuples.  For example it would "work" consistently with Common Lisp
multiple values.  And it's not clear to me that unpacking key tuples
would be used anywhere near as often as item unpacking.

But Python doesn't have other objects that behave like Common Lisp
multiple values, and it would change the meaning of currently correct
programs, so it's a non-starter.



More information about the Python-Dev mailing list