New submission from the mulhern:

The problems is that it is quite possible to define a property using @property 
in a class and then later to realize that it really ought to be a class method, 
not an instance method. But then, if you change it to a class method, using 
@classmethod annotation, the @property annotation will fail to work. If you are 
a pedantic person, and name your properties differently than you name your 
methods, you have to:
1) Change all uses of this former property back to method invocations, with a 
"()"
2) Change the name, so it now reflects that it is an actual function, not a 
property any longer.

I think an @classproperty and an @staticproperty decorator would take this 
problem away.

An alternative would be to make it possible to chain @property and 
@classmethod. I know that this is sort of doable for ABC.abstractproperty which 
is now deprecated in favor of @property combined with @ABC.abstractmethod. This 
would be ideal, but I can not pretend to know if it would be possible. Also, I 
suspect that the order would matter as it does for ABC as described in 
http://bugs.python.org/issue16267.

----------
components: Library (Lib)
messages: 211416
nosy: the.mulhern
priority: normal
severity: normal
status: open
title: Want to make a class method a property by combining decorators
type: enhancement
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20659>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to