[Types-sig] Why have two hierarchies? (*EUREKA!*)
Just van Rossum
just@letterror.com
Sat, 5 Dec 1998 20:00:21 +0100
Donald Beaudry wrote:
>But that's too simple to be any fun ;)
I *knew* it! ;-)
>Besides, now you have to answer
>the question of what object is used to represent the bases collection?
>Is it a tuple of objects, or is it just an object?
As far as I'm concerned any sequence object will do. In other words: any
object that implements __getitem__.
>...and what about
>the objects in the collection, what can we expect of them.
- that they have a __bases__ attribute
- that they have a __namespace__ attribute (without one, inheriting
makes no sense)
- that you can fetch attributes from them.
Nothing more I guess.
>What
>attributes and methods do they have?
I'd say a __getattr__ method.
>What attributes and methods does
>the collection have?
I answered that before: __getitem__...
>Where do we encode the attribute look-up policy
>for our instances?
In a custom __getattr__. That may sound primitive, but that's all there is
to it (as far as I can see). If you define a __getattr__ it will get called
for *all* attribute access: if you want to pretend you're inheriting of
something else than what __bases__ says, go right ahead! Only your
__getattr__ method must be on the __bases__ path.
>You can change the names all you want, but simplifying this mess isnt
>going to be that simple :)
What's the problem? ;-) (Seriously: I *may* just not get it: please
elaborate...)
Just