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

Donn Cave donn at u.washington.edu
Mon Mar 26 20:11:22 EST 2001


Quoth "Sean 'Shaleh' Perry" <shaleh at valinux.com>:
|
| 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?

It would be more consistent.  Right now this is a special case -
any other number N of input lists, where N != 1, returns a list of
N-tuples.

But it's also a common case, and "fixing" it would surely break lots
of code.  Can't even see how the fixed version would be more useful.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list