classmethod and instance method
andychambers2002 at yahoo.co.uk
andychambers2002 at yahoo.co.uk
Thu Feb 2 15:08:43 EST 2006
Hi,
I'm trying to write a method that needs to know both the class name and
the instance details
class A:
@classmethod
def meth(cls, self):
print cls
print self
a = A()
a.meth(a)
The above code seems to work as intended. Could the same effect be
achieved using a second decorator in addition to the @classmethod. I
tried
def instancemethod(self):
return self.meth(self)
@instancemethod
@classmethod
def meth(cls, self):
#do stuff
but it didn't work. Any suggestions?
Regards,
Andy
More information about the Python-list
mailing list