Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10928

Re: Get the name of a function

From Emile van Sebille <emile@fenx.com>
Subject Re: Get the name of a function
Date 2011-08-05 13:19 -0700
References <8295aba8-3eab-4c6e-b3b7-c3421d829220@f7g2000vba.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1940.1312575911.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 8/5/2011 11:52 AM gervaz said...
> Hi all, is there a way to retrive the function name like with
> self.__class__.__name__?

yes, but not reliably:

Python 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02:55:11)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> def test():pass
...
 >>> test.__name__
'test'
 >>> b=test
 >>> b.__name__
'test'
 >>>


Emile

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Get the name of a function gervaz <gervaz@gmail.com> - 2011-08-05 11:52 -0700
  Re: Get the name of a function Emile van Sebille <emile@fenx.com> - 2011-08-05 13:19 -0700
  Re: Get the name of a function Chris Rebert <clp2@rebertia.com> - 2011-08-05 14:19 -0700
  Re: Get the name of a function Grant Edwards <invalid@invalid.invalid> - 2011-08-05 22:05 +0000

csiph-web