Obtaining "the" name of a function/method
Tim Chase
python.list at tim.thechases.com
Sun Nov 17 14:47:26 EST 2013
On 2013-11-17 11:34, Ned Batchelder wrote:
> Functions have a __name__ attribute, which is the name they were
> defined as:
>
> >>> def foo(): pass
> ...
> >>> foo.__name__
> 'foo'
> >>> bar = foo
> >>> bar.__name__
> 'foo'
which they have even in less-than-useful situations:
(lambda s: s.lower()).__name__
accurately returns that its name is "<lambda>". So you get what you
pay for ;-)
-tkc
More information about the Python-list
mailing list