Import Error ('mutual inclusion of modules'?)
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
Re: Import Error ('mutual inclusion of modules'?)
Thanks, I had not found anything about it. But I had not search correctly. There is an entry in the FAQ about it: http://www.python.org/doc/faq/programming.html#how-can-i-have-modules-that-mutually-import-each-other I like the most the third way. I have also tried to move the import to the __init__ methos in B.py and it works. -- http://mail.python.org/mailman/listinfo/python-list
Encoding detection in the html parser from libxml2
Hi, I am parsing html documents using the html parser from libxml2, and if the encoding is included in the document it works perfectly but if it is not, I think it does not work well (probably because I am doing something wrong). As it is said in http://xmlsoft.org/encoding.html the parser should detect the encoding. So I tested it putting an utf-8 word in a file and it does not detect it (it generates a wrong string). Example: reducción --> reducción. I just use the parser as a SAX parser because I do not need a tree, so to parse the file I use the htmlParseChunk() function and I create the context with htmlCreatePushParser(). Is it posible that the encoding detection does not work with htmlParseChunk? If it is so, what method should I use? Thanks, Cesar -- http://mail.python.org/mailman/listinfo/python-list