Py2K wishes

Gordon McMillan gmcm at hypernet.com
Tue Dec 28 17:27:06 EST 1999


Paul Prescod wrote:

> > >class Proxy:
> > >       def __init__ ( self, fallback ):
> > >               __fallback__=fallback
> > 
> > >a = Proxy( someObject )
> > 
> > >This would imply the following:
> > 
> > >class SomeClass( someParentClass ): pass
> > >assert SomeClass.__fallback__ == someParentClass
> > >assert SomeClass().__fallback__ == SomeClass.__fallback__

[William Tanksley] 
> > I don't have a clue what this is doing.  Sorry.
> 
> It's doing what Python has always done with instances and their
> classes and base classes. Only now it is doing it based on a more
> explicit, generalized, reusable mechanism.

Sorry Paul, but I can't connect these statements. In class 
Proxy, I've got an instance wrapping an instance, with the 
wrap being done magically by "__fallback__". Presumably this 
means that __getattr__ and __setattr__ have been overridden 
for me. OK, now I can override methods on the wrapped 
instance by adding methods to Proxy.

But if I were doing that, I wouldn't proxy, I would subclass. 
Don't know about you, but I proxy when I'm changing the 
mechanics of an object (eg, marshalling, tracing, or some 
meta-behavior), not twiddling with methods.

Your implications don't make sense to me, either. Does the 
first assert imply that MI is passe? Does the second imply 
that the difference between bound and unbound methods (and 
the reasons for the difference) have disappeared?


- Gordon




More information about the Python-list mailing list