Robin Becker wrote:
import inspect
class A:
_class_name=inspect.currentframe().f_code.co_name
def __init__(self,text,_defining_class_name=_class_name):
print 'text=',text,'_defining_class_name=',_defining_class_name
class B(A):
pass
b=B('aaa')
That won't work, if you, say, wanted to print
Michael Hoffman wrote:
Robin Becker wrote:
self.__class__.__name__
Unless I misunderstood the question, that won't work. That will
give you the name of the class the object is an instance is of.
I think he wants the name of the class the method was defined in.
Here's a way to do that using metacla
John Roth wrote:
If that's the case, then the inspect module should give
the tools to do it without a great deal of angst. Unfortunately,
it doesn't give you the class that defined the method, just
the class that invoked it.
Are you saying that the inspect module *should* give you the
tools to do i
Diez B. Roggisch wrote:
>[Michael Hoffman]:
Unless I misunderstood the question, that won't work. That will
give you the name of the class the object is an instance is of.
I think he wants the name of the class the method was defined in.
Where is the difference? The method is defined in a class - a
"Michael Hoffman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Robin Becker wrote:
self.__class__.__name__
Unless I misunderstood the question, that won't work. That will
give you the name of the class the object is an instance is of.
I think he wants the name of the class the metho
> Unless I misunderstood the question, that won't work. That will
> give you the name of the class the object is an instance is of.
> I think he wants the name of the class the method was defined in.
Where is the difference? The method is defined in a class - and an instance
is created from that c
Robin Becker wrote:
self.__class__.__name__
Unless I misunderstood the question, that won't work. That will
give you the name of the class the object is an instance is of.
I think he wants the name of the class the method was defined in.
Here's a way to do that using metaclasses and Python's magic
[EMAIL PROTECTED] wrote:
...
My question is this: what can be substituted for that will
make the example above work?
self.__class__.__name__
--
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list