Accessing overridden __builtin__s?
garyjefferson123 at yahoo.com
garyjefferson123 at yahoo.com
Tue Mar 14 00:28:06 EST 2006
I'm having a scoping problem. I have a module called SpecialFile,
which defines:
def open(fname, mode):
return SpecialFile(fname, mode)
class SpecialFile:
def __init__(self, fname, mode):
self.f = open(fname, mode)
...
The problem, if it isn't obvioius, is that the open() call in __init__
no longer refers to the builtin open(), but to the module open(). So,
if I do:
f = SpecialFile.open(name, mode)
I get infinite recursion.
How do I tell my class that I want to refer to the __builtin__ open(),
and not the one defined in the module?
Thanks,
Gary
More information about the Python-list
mailing list