[issue4337] Iteration over a map object with list()

2008-11-21 Thread Terry J. Reedy
Terry J. Reedy [EMAIL PROTECTED] added the comment: Dict views and range objects are *iterables* because they are based on reusable information. Map, filter, and similar objects are *iterators* because they are based on iterables that could be once-through iterators. The built-in function

[issue4337] Iteration over a map object with list()

2008-11-17 Thread Jean-Michel Fauth
New submission from Jean-Michel Fauth [EMAIL PROTECTED]: win XP sp2, Py3.0c2 I had to face an annoying problem when iterating over a map object. With a range class, this works r = range(5) list(r) [0, 1, 2, 3, 4] With dict_keys/values/items objects, the following works d = {1: 'a',

[issue4337] Iteration over a map object with list()

2008-11-17 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: Feature :-) You will get the expected result if you skip the step where you ran the for-loop over r before running list(). Either listing or for-looping will exhaust the iterator. This is how iterators work. -- nosy: +rhettinger

[issue4337] Iteration over a map object with list()

2008-11-17 Thread Jean-Michel Fauth
Jean-Michel Fauth [EMAIL PROTECTED] added the comment: 2008/11/17 Raymond Hettinger [EMAIL PROTECTED] Raymond Hettinger [EMAIL PROTECTED] added the comment: Feature :-) You will get the expected result if you skip the step where you ran the for-loop over r before running list(). Either