Prasad, Ramit wrote:

> Jim Mooney wrote:
>> 
>> > In py3.x, iteritems was replaced by .items()
>> 
>> Interesting, since iteritems was in my book, which was "updated" for
>> Py33. I guess the moral is you shouldn't trust an author 100% ;')  I
>> must admit, iteritems did seem awkward and annoying so I'm glad it's
>> dropped.
>> 
>> Jim
> 
> Technically, .items() was dropped and .iteritems() was renamed .items()

One way to verify that is to run 

$ cat tmp.py
d = dict(a=1, b=2)
x = d.items()
y = d.iteritems()
z = d.viewitems()

through the 2to3 tool:

$ 2to3 tmp.py 2> /dev/null
--- tmp.py      (original)
+++ tmp.py      (refactored)
@@ -1,5 +1,5 @@
 d = dict(a=1, b=2)
-x = d.items()
-y = d.iteritems()
-z = d.viewitems()
+x = list(d.items())
+y = iter(d.items())
+z = d.items()

So

d.items() --> list(d.items())
d.iteritems() --> iter(d.items())
d.viewitems() --> d.items()

In short: items() and iteritems() were both dropped, and viewitems() was 
renamed items().


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to