my Python lib is broken

Guilherme Polo ggpolo at gmail.com
Sat Oct 6 08:22:30 EDT 2007


2007/10/6, Bruno Rezende <brunovianarezende at gmail.com>:
> 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:
>
> >>> import xml
> >>> xml.dom
> 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:
>
> >>> from xml import *

Doing that will cause the __init__.py inside package xml to check its
__all__ list and import them all, including dom

> >>> xml.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 =)

>
> regards,
> Bruno
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves



More information about the Python-list mailing list