[Tutor] getting the current method name
Fri Apr 18 17:58:44 2003
> how to do the following:
> class x:
> def y():
> print "Hi, my name is",<<method-name --> 'y'>>
> Of course, resolving "<<method-name --> 'y'>>" should not be done
> simply 'y' :-)
I'm curious why there would ever be such a need? I can't think
of a situation when simply hard coding the name woulfd not be
possible, after all you are writing the,method when you do it.
I guess the only case might be using a callable object for
dynamic object creation.
c = C()
c.f = lambda self: "My name is .....
But no even here we know that the name will be f.
I give in, under what circumstance would you not know the
current method's name?