As usual, Alex's posts are long and illuminating, but there is one point where I think he misrepresented me (a bit) On Wed, 4 Apr 2001 12:14:09 +0200, "Alex Martelli" <aleaxit at yahoo.com> wrote: [about using object.method=callable to override object.__class__.method] > (e.g., Moshe and others are on record as stating that they > strongly believe an object's __class__ should always change > if its behavior does -- i.e., they see the class/behavior > decoupling as an undesirable language feature, never to be > actually _used_) Let me clarify my position, since I do think this is a language feature. What I said is that adding *methods* (that is, Python functions with first argument bound to the object) is better done with __class__ mangling -- not that all behaviours do. See the ProxyHandler in urllib2 (Jeremy wrote that, for history's sake) as a place I think this technique is used to very good effect. Of course, that made documenting urllib2 close to impossible (see the documentation for the controtions I had to go through to properly document it ;-) Personally, other then the type-class dichotomy, I find Python's object model perfect -- while I do occasionally find faults in the language, none have been found by me in the object model. Well, the only slight wart is that custom setters and getters are *a bit* hard to get right -- I'd love something like __get_[attribute]__ and __set_[attribute]__ as "surgical getters and setters". -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4