[Tutor] print method name

rail shafigulin rail.shafigulin at gmail.com
Thu Dec 8 16:56:10 CET 2011


On Thu, Dec 8, 2011 at 10:17 AM, Joel Goldstick <joel.goldstick at gmail.com>wrote:

>
>
> On Thu, Dec 8, 2011 at 9:49 AM, rail shafigulin <rail.shafigulin at gmail.com
> > wrote:
>
>> i created a class and in some instances when i use it call some of its
>> methods i need to print a method name. the online search did produce some
>> results but none of them seem to work for me. for example one of them said
>> just to use __name__ or func_name but it didn't work for me. i'm using
>> python 3.1.1
>>
>> any help is appreciated.
>>
>> It would be better if you send us the code you tried.  I'm not sure what
> you are looking to do.  When you invoke the method, do you want it to print
> its own name?
>
>
> class A(object):
> ...   def first(self):
> ...     pass
> ...
> >>> a = A()
> >>> a.first.__name__
> 'first'
>
>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
>
> --
> Joel Goldstick
>
>
folks, never mind. i'm not sure what went wrong when i ran my code and got
an error. i ran it again and it is working fine. my sincere apologies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111208/ae0f533f/attachment.html>


More information about the Tutor mailing list