Import Error ('mutual inclusion of modules'?)

I

icoba

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top