Class Methods (as opposed to Instance Methods)
Olivier Deckmyn
olivier.deckmyn at mail.dotcom.fr
Fri Aug 20 07:45:53 EDT 1999
Hi,
I play with Python while a few now (1 month).
My programer background is ObjectPascal, C++ and SmallTalk.
There is an "object-feature" I am not able to reproduce with Python : class
method.
As opposed to instance methods, theese should apply to classes.
ex:
class MyClass:
def myInstanceMethod(self):
print "spam"
def myClassMethod(?, value):
if value=='1' :
return 'MyClass'
elif value=='2' :
return 'Something'
else: return 'What else?'
Instance methods are easy to use:
instance=MyClass()
instance.myInstanceMethod()
But here is how I would like to use class Methods :
print MyClass.myClassMethod(2)
(Note that there is no MyClass().xxx but well MyClass.xxx)
I don't find any way to do that :(
I know it exists class attributes, but it does not fit my needs :(
Please HEEEELP !
---
Olivier Deckmyn, Paris - France
"Any sufficiently advanced technology is indistinguishable from
magic." -Arthur C. Clark
More information about the Python-list
mailing list