Peter Otten wrote: > 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(). >
Thanks for the excellent (and well laid out) correction Peter! ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor