Bind an instance of a base to a subclass - can this be done?
Lou Pecora
pecoraREMOVE at THISanvil.nrl.navy.mil
Thu May 25 09:17:21 EDT 2006
In article <4djshnF1asdovU1 at uni-berlin.de>,
"Diez B. Roggisch" <deets at nospam.web.de> wrote:
> Lou Pecora schrieb:
[cut]
> >
> > Then do something like (I know this isn't right, I'm just trying to
> > convey the idea of what I would like)
> >
> > mf=myfile()
> >
> > mf=open("Afile","r")
> > Possible in some way? Thanks in advance for any clues.
>
> Nope, not in that way. But you might consider writing a proxy/wrapper
> for an object. That looks like this (rouch sketch from head):
>
> class FileWrapper(object):
> def __init__(self, f):
> self._f = f
>
> def __getattr__(self, name):
> return getattr(self._f, name)
>
> def myreadline(self):
> ....
>
> Then you do
>
> f = FileWrapper(open(name, mode))
>
> Diez
Interesting. I have to think about this to understand if it is a
solution I can use. But, thank you for a very different angle on this.
-- Lou Pecora (my views are my own) REMOVE THIS to email me.
More information about the Python-list
mailing list