Circular import

Frank V. Castellucci frankc at colconsulting.com
Mon Jun 19 00:06:56 EDT 2000


Darrell Gallion wrote:
>
> From: "Frank V. Castellucci" <frankc at colconsulting.com>
> >
> > With the assumption that class A and class B reference each other, how
> > do you avoid the Python error with:
> >
> > ---------- Composite.py -----------
> >
> > from Leaf import Leaf
> >
> > class Composite:
> > def __init__( self ):
> > self.__theLeaf = Leaf(self)
> >
> > -------- Leaf.py --------------
> >
> > from Composite import Composite
> >
> > class Leaf:
> > def __init__( self, aComposite ):
> > self.__theComposite = aComposit
> >
> >
>
> I'm guessing you come from the land of C++, where the compiler wants to know
> every detail.
> Don't bother with this:
> > from Composite import Composite
>
> Leaf can accept any kind of object as the composite.
> What ever methods the Composite has will be accessible.
> It's a beautiful thing once you get the hang of it.
>
> --Darrell Gallion

Thanks!

--
Frank V. Castellucci



More information about the Python-list mailing list