At 05:28 PM 9/28/2005 +0000, iga Seilnacht wrote: >You can use something like this to find a descriptor's name: > <snip>
The given code fails if the same property appears under more than one name or is used in more than one class. It also requires the property object to be mutable, and is subject to inter-thread race conditions in the case of modification of a class. It also doesn't work for class-level descriptors (added to the class' class), and I'd prefer it to use the logical equivalent of ob.__dict__.setdefault() rather than setattr(ob,...) so that it's free of (simple) race conditions in the case where one thread sets the attribute while another is computing the default value. While these aren't crippling limitations in a given application, I think the stdlib implementation should be a bit more robust, especially since none of these features is very hard to implement, once you know what's needed. (And I already have a robust implementation that could be cribbed from.) In any case, having a stdlib version that doesn't address those issues wouldn't be very useful for me, as it wouldn't allow me to replace my custom C descriptor and metaclass. If we added __bind__ (or something like it) to the descriptor protocol I could get rid of *at least* that metaclass, and maybe others. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com