Py2K wishes

Paul Prescod paul at prescod.net
Tue Dec 28 17:10:13 EST 1999


Skip Montanaro wrote:
> 
> ...
> Please explain for those of us with small brains.

When you can't find something in the current function namespace, Python
"falls back" to the global namespace. When it can't find something
there, it "falls back" to the __builtins__ namespace. When Python can't
find something in an object instance it "falls back" to the object's
class object. When it can't find something there it "falls back" to the
class's base class. And so forth.

The "fallback" code is presumably very optimized and is of course
written in Python. It is often the case that I want to have a an
instance that "falls back" to some other instance. For instance I might
have an object that almost does what I want but I need to wrap some of
the methods to be Unicode aware. The other methods should just "fall
back" automatically. This sort of proxying is also useful for working
around cycles. Typically we code this by hand using __getattr__. 

I'm saying that we could expose the fallback mechanism so that an object
could be instructed to fallback to another object.

 Paul Prescod




More information about the Python-list mailing list