Mapping None. Why?
Diez B. Roggisch
deets at nospam.web.de
Thu Jun 12 15:55:55 EDT 2008
Ian Kelly schrieb:
> On Thu, Jun 12, 2008 at 1:32 PM, Diez B. Roggisch <deets at nospam.web.de> wrote:
>> Because it is undefined what should happen in case of no function given at
>> all - and because there is no identity function in python pre-defined, it
>> could be considered sensible to make None the quivalent of that function.
>
> It makes more sense to raise an error when a non-function is passed
> where a function is expected. If we're going to have a special
> behaviour for None, why not have special behaviours for True, False,
> and 42 as well? The proper solution to the lack of a built-in packing
> (not identity) function is to define a packing function, not to
> special-case an arbitrary value to *mean* the packing function in
> certain situations.
You are right with the packing-function, it's not identity of course.
However I don't see that this as an area that is really important
(especially since map is being replaced by list-comps most of the time).
And the OP's question was about map not being conforming to the
definition on wikipedia - which I don't think it's not. It is not
defined what map is to do with None (or NULL or nil or... ) as argument.
Diez
More information about the Python-list
mailing list