Op 2005-02-28, Daniel Dittmar schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >>>>Can anyone explain why descriptors only work when they are an attribute >>>>to an object or class. I think a lot of interesting things one can >>>>do with descriptors would be just as interesting if the object stood >>>>on itself instead of being an attribute to an other object. >>> >>>How would that work? >> >> >> Well AFAIU a descriptor is an object with at least one method out of >> __get__, __set__ or __del__. I don see why implicitly calling one >> of these methods would be any more difficult when they are autonomous >> objects than when they are attributes. > > I guess properties are really a feature of the class, not of the > attribute. Certain operations on objects of the class (getattr, setattr, > delattr) have to be intercepted. If you want to have this for general > variable access, you 'd have to intercept all accesses to local and > module name spaces. This slows things down a lot.
OK, I can understand this. > And many think that > overloading assignment is a bad idea. But not bad enough to allow it in some cases? > You probably find some dicussions > when searching for "overloading assignment" in the newsgroup archive. I'll take a look. > >>>to an object or class. I think a lot of interesting things one can > > As in the chinese curse "May you live in interisting times"? Well I think python partly makes the time interesting. So in that respect we are all cursed. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list