I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter:
>>> class foo(object):
... _var=5
... def getvar(cls):
... return cls._var
... getvar=classmethod(getvar)
... def setvar(cls,value):
... cls._var=value
... setvar=classmethod(setvar)
... var=property(getvar,setvar)
...
>>> f.getvar()
5
>>> f.setvar(4)
>>> f.getvar()
4
>>> f.var
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'classmethod' object is not callable
>>> f.var=5
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'classmethod' object is not callable
Is it possible to use the property() function with classmethod decorated functions?