I'll note this general problem is also present in any of the declarative ORMs, which use silly hacks to tell descriptors their name.  Like you have:<br><br>class Table(ORM):<br>    name = StringColumn()<br><br>Another case where I've noticed a problem is any kind of descriptor that needs its own storage; the name of the property gives a possible stable namespace for the value, but without the name you either have to pass in a name or the storage area becomes volatile.  For instance, a read-only descriptor: <a href="http://svn.colorstudy.com/home/ianb/recipes/setonce.py">http://svn.colorstudy.com/home/ianb/recipes/setonce.py</a><br>

<br>You can solve this in, e.g., the ORM class by doing things when a class is created -- but it requires very specific cooperation between the class and the descriptor.  Everyone really does it different ways.<br><br>One could imagine an extension of the descriptor protocol, where on class creation you called something like attr.__addtoclass__(cls, name) (for all attributes of the class that define that method) -- which if you just want the name you'd simply save that name in your object and return self.<br>

<br><br><br><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 4:28 AM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I just experienced an obscure bug resulting from copying<br>
and pasting an overridable_property and forgetting to<br>
change the passed-in name:<br>
<br>
  content_size = overridable_property('size',<br>
    "Size of the content area.")<br>
<br>
which should have been<br>
<br>
  content_size = overridable_property('content_size',<br>
    "Size of the content area.")<br>
<br>
This was quite difficult to track down, because the result<br>
was to effectively make it an alias of *another* property<br>
I have called 'size'. They happen to be near enough to the same<br>
thing that the error went unnoticed for quite some time.<br>
<br>
If I could write my overridable_property declarations<br>
without having to repeat the name, this kind of thing would<br>
not be able to happen.<br><font color="#888888">
<br>
-- <br>
Greg<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</font></blockquote></div><br>