Accessing method object from within a method
Peter Hansen
peter at engcorp.com
Wed Feb 18 18:09:57 EST 2004
> Vivek Sawant wrote:
>
> I had browsed through documentation for frame objects earlier, but nothing
> had jumped out. Here's what your suggestion helped me conjur up and it worked:
>
> def method (self, ...)
> mname = sys._getframe(0).f_code.co_name;
> # do something with mname
>
> Is this what you had in mind or did you mean to suggest something better?
That's about it. By referring to frame objects, I meant to lead you to
the stuff which you found so that you could see the extent of information
aside from just function name, which is available to you. Enjoy! :)
-Peter
More information about the Python-list
mailing list