python-dev
[Prev] Thread [Next] | [Prev] Date [Next]
[Python-Dev] Import semantics Fabio Zadrozny Sat Sep 02 12:58:37 2006
Python and Jython import semantics differ on how sub-packages should be accessed after importing some module: Jython 2.1 on java1.5.0 (JIT: null) Type "copyright", "credits" or "license" for more information.
import xml xml.dom
<module xml.dom at 10340434> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import xml xml.dom
Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'module' object has no attribute 'dom'
from xml.dom import pulldom xml.dom
<module 'xml.dom' from 'C:\bin\Python24\lib\xml\dom\__init__.pyc'> Note that in Jython importing a module makes all subpackages beneath it available, whereas in python, only the tokens available in __init__.py are accessible, but if you do load the module later even if not getting it directly into the namespace, it gets accessible too -- this seems more like something unexpected to me -- I would expect it to be available only if I did some "import xml.dom" at some point. My problem is that in Pydev, in static analysis, I would only get the tokens available for actually imported modules, but that's not true for Jython, and I'm not sure if the current behaviour in Python was expected. So... which would be the right semantics for this? Thanks, Fabio
_______________________________________________ Python-Dev mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/alexiscircle%40gmail.com
- [Python-Dev] Import semantics Fabio Zadrozny <=
- Re: [Python-Dev] Import semantics Terry Reedy
- Re: [Python-Dev] Import semantics Samuele Pedroni
- Re: [Python-Dev] Import semantics Guido van Rossum
- Re: [Python-Dev] Import semantics Frank Wierzbicki
- Re: [Python-Dev] Import semantics Guido van Rossum
- Re: [Python-Dev] Import semantics Anthony Baxter
- Re: [Python-Dev] Import semantics Guido van Rossum
- Re: [Python-Dev] Import semantics Frank Wierzbicki
- Re: [Python-Dev] Import semantics Frank Wierzbicki
- Re: [Python-Dev] Import semantics skip