[Python-Dev] Re: Nested functions and class scope
Fredrik Lundh
fredrik@pythonware.com
Tue, 14 Nov 2000 15:09:37 +0100
John Max Skaller wrote:
> Do you have an example of real application code where searching a class
> in which a function is defined will break code?
I haven't been following this thread closely, but are we talking
about a scoping model where a class can override any built-in
function or method by defining a method (or a class attribute)
with the same name?
like in urllib.py, for example:
class URLopener:
...
def open(self, fullurl, data=None):
fullurl = unwrap(fullurl)
if self.tempcache and self.tempcache.has_key(fullurl):
filename, headers = self.tempcache[fullurl]
fp = open(filename, 'rb')
return addinfourl(fp, headers, fullurl)
...
this won't fly.
</F>