Would Anonymous Functions Help in Learning Programming/Python?

Duncan Booth duncan.booth at invalid.invalid
Mon Sep 24 12:57:04 CEST 2007


Carsten Haese <carsten at uniqsys.com> wrote:

> It comes from the 'new' module:
> 
>>>> import new
>>>> help(new.function)
> Help on class function in module __builtin__:
> ...
> 
> Oddly enough, the help misrepresents which module the function is coming
> from.

No, I don't think it is misrepresenting anything. The 'new' module simply 
exposes names for some things which don't otherwise  have names, none of 
the types accessible through that module are actually defined there.

The class 'function' is a builtin definition, but by default it isn't bound 
to any name accessible to the Python interpreter. If you do:

>>> def f(): pass

>>> type(f).__module__
'__builtin__'
>>> help(type(f))
Help on class function in module __builtin__:
... etc ...

then the help makes a bit more sense.




More information about the Python-list mailing list