Retrieving the name of the class calling an instance method
mercado mercado
mercado949 at gmail.com
Fri Sep 5 11:29:39 EDT 2008
In Python, is it possible for an instance method to know the name of the
class which is calling it? For example, in the sample below, I would like
for the someMethod method to print the name of the class calling it ("bar"
in the first case, "again" in the second).
---------------------------------------
class foo():
def someMethod(self):
print x
class bar():
def __init__(self):
f = foo()
f.someMethod()
class again():
def __init__(self):
f = foo()
f.someMethod()
bar()
again()
---------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080905/e93870b0/attachment.html>
More information about the Python-list
mailing list