fixing map(None, [1,2,3]) ?

Ben Wolfson wolfson at midway.uchicago.edu
Mon Mar 26 20:00:24 EST 2001


In article <mailman.985648235.13881.python-list at python.org>,
Sean 'Shaleh' Perry <shaleh at valinux.com> wrote:
>
>On 26-Mar-2001 Mike Coleman wrote:
>> Shouldn't "map(None, [1,2,3])" return "[(1,), (2,), (3,)]"?
>> 
>> Is there any hope that this could be fixed?
>> 
>
>map runs the function on each element of the list it is passed and returns an
>element of a new list.  Why should it magically return a list of one-tuples?


>>> def t(*a): return a
...
>>> map(None, range(3), range(4,7))
[(0,4), (1,5), (2,6)]
>>> map(t, range(3), range(4,7)) #same as None
[(0,4), (1,5), (2,6)]

>>> map(None, range(3))
[0, 1, 2]
>>> map(t, range(3))             #differnt
[(0,), (1,), (2,)]





-- 
Barnabas T. Rumjuggler
Fried Something with Noodle:  Very good for ugly, sad, lonely, sick
people with the blood and the grasses all over the floor...
 -- Joe Frank, _A Call in the Night_



More information about the Python-list mailing list