my Python lib is broken

B

Bruno Rezende

Hi,

I think I've broken my python installation (don't know how). All the
packages that are under 'lib' in python installation doesn't work the
way expected:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dom'

but, if I import * from xml, it starts to work again:
<module 'xml.dom' from 'C:\Python25\Lib\xml\dom\__init__.pyc'>


Does someone know why is this happening? (I can reinstall my python
2.5, but would like to know how the python lib got broken).

regards,
Bruno
 
G

Guilherme Polo

2007/10/6 said:
Hi,

I think I've broken my python installation (don't know how). All the
packages that are under 'lib' in python installation doesn't work the
way expected:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'dom'

This is not broken. It is how packages works.
xml is a package, dom is a package inside xml. If you want to check
the attributes that you get importing xml you do dir(xml)
but, if I import * from xml, it starts to work again:

Doing that will cause the __init__.py inside package xml to check its
__all__ list and import them all, including dom
<module 'xml.dom' from 'C:\Python25\Lib\xml\dom\__init__.pyc'>


Does someone know why is this happening? (I can reinstall my python
2.5, but would like to know how the python lib got broken).

This is hapenning because you have installed Python, congratulations =)
 
B

Bruno Rezende

Thanks for the information! Indeed, I was geting an error when trying
to do:

from xml.dom import minidom

but it was because there is a xml.py file inside the same package, so
it happens a conflict...
 

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,780
Messages
2,569,609
Members
45,253
Latest member
BlytheFant

Latest Threads

Top