mutlifile inheritance problem

Marc maurelius01 at hotmail.com
Thu Mar 21 18:08:58 EST 2002


Aahz wrote:
> 
> In article <9896e047.0203211303.741f695a at posting.google.com>,
> Marc <maurelius01 at hotmail.com> wrote:
> >
> >************************
> >file cbase01.py:
> >
> >class CBase:
> >    def __init__(self):
> >        self.cclass = None
> >        print "cbase"
> >
> >class CImStream(CBase):
> >    def __init(self):
> >        CBase.__init__(self)
> >        print "CImStream"
> >
> >*************************
> >in file wrappers_A01.py:
> >
> >import cbase01
> >reload(cbase01)
> >
> >class ImStream_SavedBitmaps(cbase01.CImStream):
> >    def __init__(self):
> >        cbase.CImStream.__init__(self)
> >        print "SavedBitmaps"
> 
> Try:
> 
>     def __init__(self):
>         cbase01.CImStream.__init__(self)
> 
> Why are you using reload(), anyway?
> --
> Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/
> 
> "We should forget about small efficiencies, about 97% of the time.
> Premature optimization is the root of all evil."  --Knuth

Oops.  That was a typo, but the same problem still
exists when I fix it.  (Originally, I had the line
cbase = cbase01 in there but I took it out before
posting. Then when I reran the program it still
worked because cbase was still loaded from the
previous run.)
I have the reload in there because I'm developing
this program now and I want to be able to change
different files without tracking down all of the
dependencies each time.  Is there another way?  Is
there a reason not to have it in?  I do think that
it's part of the problem, because the program
works if I remove it.  But I have no idea why I
must remove it, or what I'm doing wrong here that
makes reload a problem.
So here is my basic question: should I be able to
inherit class from another file.  The docs has the
statement:
""""There is a simple way to call the base class
method directly: just call
"BaseClassName.methodname(self, arguments)". This
is
occasionally useful to clients as well. (Note that
this only works if the base class is defined or
imported directly in the global scope.)"""
Does this mean the inherited class must be in the
same file if I'm to directly call a base class
member?  Or am I just hungup in some problem with
"reload".



More information about the Python-list mailing list