Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Python's iter() on a mapping return iterkeys() instead of iteritems()?

It seems like if you want to get the keys of a mapping, you ask for them; otherwise, give me the whole mapping (constituted by a set of key-value pairs). Is there a historical reason for this?

like image 936
cdleary Avatar asked Aug 30 '08 01:08

cdleary


1 Answers

Check out this thread for a discussion on the reasons behind this behavior (including that Guido likes it, and it's not likely to change).

like image 63
dF. Avatar answered Nov 03 '22 11:11

dF.