<div class="gmail_quote">On Tue, Jan 4, 2011 at 7:09 AM, K. Richard Pixley <span dir="ltr"><<a href="mailto:rich@noir.com">rich@noir.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
I think the meanings of the new ones are pretty straightforward, but
in case they are not...<br>
<br>
@staticproperty - like @property only without an implicit first
argument. Allows the property to be called directly from the class
without requiring a throw-away instance.<br>
<br>
@classproperty - like @property, only the implicit first argument to
the method is the class. Allows the property to be called directly
from the class without requiring a throw-away instance.<br></div></blockquote><div><br>As Michael mentions later in the thread, these can't really work due to the asymmetry in the descriptor protocol: if you retrieve a descriptor object directly from a class, the interpreter will consult the __get__ method of that descriptor, but if you set or delete it through the class, it will just perform the set or delete - the descriptor has no say in the matter, even if it defines __set__ or __delete__ methods. (See the example interpreter session at <a href="http://pastebin.com/1M7KYB9d">http://pastebin.com/1M7KYB9d</a>).<br>
<br>The only way to get static or class properties to work correctly is to define them on the metaclass, in which case you can just use the existing property descriptor (although you have to then jump through additional hoops to make access via instances work properly - off the top of my head, I'm actually not sure how to make that happen). <br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000">
@abc.abstractattribute - a simple, non-callable variable that must
be overridden in subclasses<br></div></blockquote><div><br>You can't decorate attributes, only functions.<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
@abc.abstractstaticproperty - like @abc.abstractproperty only for
@staticproperty<br>
<br>
@abc.abstractclassproperty - like @abc.abstractproperty only for
@classproperty<br></div></blockquote><br>See above. These don't exist because staticproperty and classproperty don't work.<br><br>Cheers,<br>Nick.<br clear="all"></div><br>-- <br>Nick Coghlan | <a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a> | Brisbane, Australia<br>