About this question
Are there any applicable differences between dict.items() and dict.iteritems()?
From the Python docs:
dict.items(): Return a copy of the dictionary’s list of (key, value) pairs.
dict.iteritems(): Return an iterator over the dictionary’s (key, value) pairs.
If I run the code below, each seems to return a reference to the same object. Are there any subtle differences that I am missing?
a={1:'one',2:'two',3:'three'}
print 'a.items():'
for k,v in a.items():
if d[k] is v: print 'tthey are the same object'
else: print 'tthey are different'
print 'a.iteritems():'
for k,v in a.iteritems():
if d[k] is v: print 'tthey are the same object'
else: print 'tthey are different'
Output-
a.items():
they are the same object
they are the same object
they are the same object
a.iteritems():
they are the same object
they are the same object
they are the same object