This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jmfauth
Recipients jmfauth
Date 2008-11-17.15:54:34
SpamBayes Score 0.023073573
Marked as misclassified No
Message-id <1226937276.11.0.323552231555.issue4337@psf.upfronthosting.co.za>
In-reply-to
Content
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', 2:'b', 3:'c'}
>>> list(d.keys())
[1, 2, 3]
>>> list(d.values())
['a', 'b', 'c']
>>> list(d.items())
[(1, 'a'), (2, 'b'), (3, 'c')]

But with a map object...

>>> def plus(i):
        return i + 1

>>> a = list(range(3))
>>> a
[0, 1, 2]
>>> r = map(plus, a)
>>> r
<map object at 0x01371570>
>>> for e in r: print(e)

1
2
3
>>> list(r)
[]
>>> #empty list!

Bug or feature?
History
Date User Action Args
2008-11-17 15:54:37jmfauthsetrecipients: + jmfauth
2008-11-17 15:54:36jmfauthsetmessageid: <1226937276.11.0.323552231555.issue4337@psf.upfronthosting.co.za>
2008-11-17 15:54:35jmfauthlinkissue4337 messages
2008-11-17 15:54:34jmfauthcreate