I have the following code:

A.py
====

from B import B

class R:
        def __str__(self):
                return "hello world"

b = B()
print b


B.py
====

from A import R


class B:

        def __init__(self):
                self.r = R()

        def __str__(self):
                return self.r.__str__()

When I try to execute A.py I get the following error:

[python2.3]$ python A.py
Traceback (most recent call last):
  File "A.py", line 1, in ?
    from B import B
  File "python2.3/B.py", line 1, in ?
    from A import R
  File "python2.3/A.py", line 1, in ?
    from B import B
ImportError: cannot import name B


I think python does not support this kind of 'mutual inclusion'. Am I
right? Thanks. Cesar.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to