Is this an inconsistency?

apardon at trout.vub.ac.be apardon at trout.vub.ac.be
Tue Mar 27 09:59:46 CEST 2001


On 26 Mar 2001 12:32:05 GMT,
Remco Gerlich <scarblac at pino.selwerd.nl> wrote:
>apardon at trout.vub.ac.be <apardon at trout.vub.ac.be> wrote in comp.lang.python:
>>   map(None , list)
>> 
>> Doesn't turn into a list of singletons but
>> just returns the list.
>> 
>> This seems a bit odd to me because if you
>> use apply with a single parameter function
>> the second argument has to be either a singleton
>> or a list with one element.
>> 
>> 
>> My question now: Is this behaviour changed in
>> the following versions? If not, wouldn't it be
>> more consistent if it was?
> 
>It's inconsistent if you see it this way, yes. On the other hand, if you
>think of different functions to call map with that take one argument, it's
>pretty nice that map(None, l) just returns l unchanged. It would be weird if
>the 'None' function made tuples.

It  wouldn't be the None function that made tuples. It is the map
function that prepares tuples so that they can be applied to  the
function.  So  if  the map function prepares tuples, if more than
one list is given it should IMO prepare singletons if only a sin-
gle list is given.

One  should also consider should one for the sake of the exercise
try to implement map onseself, with the help of the  apply  func-
tion, that apply expects a singleton if used with a single param-
eter, so that it is logical that the map function would deliver a
singleton for processing, which the None function would leave un-
changed.

-- 
Antoon Pardon



More information about the Python-list mailing list