John Krukoff <[EMAIL PROTECTED]> added the comment: I assume when you say that the documentation has already been updated, you mean something other than what's shown at: http://docs.python.org/dev/reference/datamodel.html#new-style-and- classic-classes or http://docs.python.org/dev/3.0/reference/datamodel.html#new-style-and- classic-classes ?
As both of those claim to still not be up to date in relation to new style classes, and the __getattr__ & __getattribute__ sections under special names make no reference to how magic methods are handled. Additionally, the "Class Instances" section under the type heirachy makes mention of how attributes are looked up, but doesn't mention the new style differences even in the 3.0 documentation. Sure, there's this note under "Special Method Names": For new-style classes, special methods are only guaranteed to work if defined in an object’s class, not in the object’s instance dictionary. But that only helps you figure it out if you already know what the problem is, and it's hardly comprehensive. I'm not arguing that this is something that's going to change, as we're way past the point of discussion on the implementation, but this looks far more annoying if you're looking at it from the perspective of proxying to container classes or numeric types in a generic fashion. My two use cases I've had to convert are for lazy initialization of an object and for building an object that uses RPC to proxy access to an object to a remote server. In both cases, since they are generic proxies that once initialized are supposed to behave exactly like the proxied instance, the list of magic methods to pass along is ridiculously long. Sure, I have to handle __copy__ & __deepcopy__, and __getstate__ & __setstate__ to make sure that they return instances of the proxy rather than the proxied object, but other than that there's over 50 attributes to override for new style classes just to handle proxying to numeric and container types. It's hard to get fancy about it too, as I can't just dynamically add the needed attributes to my instances by looking at the object to be proxied, it really has to be a static list of everything that python supports on the class. Additionally, while metaclasses might help here, there's still the problem that while my old style proxy class has continued to work fine as magic attributes have been added over python revisions, my new style equivalent will have to be updated work currectly as magic methods are added. Which, given the 2.x track seems to happen pretty frequently. Some of the bugs from that would have been quite tricky to track down too, such as the __cmp__ augmentation with the rich comparison methods. None of the solutions really seem ideal, or at least as good as what old style classes provided, which is why I was hoping for some support in the 3.0 standard library or the conversion tool. ____________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue643841> ____________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com