[Edu-sig] Technical question
Kirby Urner
pdx4d@teleport.com
Thu, 10 May 2001 15:08:05 -0700
I have a pyfraction.py and a polynomial.py, which contain
Fraction and Poly classes respectively.
My problem is each class needs to know about the other,
meaning I'm now doing an isinstance(other,Fraction) in
Poly, and an isinstance(other,Poly) in Fraction.
So how do I handle this. I have an
import Fraction from pyfraction
at the top of polynomial.py, and an
import Poly from polynomial
at the top of pyfraction.py
This is obviously NOT the way to handle it, because
it's a loop. In trying to import Fraction, it hits the
line to import polynomial, which it's still trying to
deal with.
This problem arises now that I'm using isinstance(foo,bar)
and need bar as a global. Earlier, I was doing
type(foo).__class__.__name__ == "bar", which was ugly,
but didn't require that I actually have any bars hangin'
around.
Kirby