This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python accepts illegal "import mod.sub as name" syntax
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amiseler, brett.cannon, logistix
Priority: normal Keywords:

Created on 2003-03-19 12:44 by amiseler, last changed 2022-04-10 16:07 by admin. This issue is now closed.

Messages (5)
msg15191 - (view) Author: Alexander Miseler (amiseler) Date: 2003-03-19 12:44
http://python.org/doc/current/ref/import.html
"To avoid confusion, you cannot import modules with
dotted names as a different local name. So import
module as m is legal, but import module.submod as s is
not."

sadly the interpreter accepts the illegal form without
comment which makes it "semi-legal".
packages that rely on this illegal form may cause
trouble with costum import implementations (i.e.
importing from zip file or similar)

tested with 2.2.2 and 2.3a2
msg15192 - (view) Author: Grant Olson (logistix) Date: 2003-03-25 22:21
Logged In: YES 
user_id=699438

Here's a case where I think the documentation should be 
fixed instead of the bug.  Every COM project I do starts 
with 'import win32com.client as client'.  I also don't see how 
one syntax is any more confusing than the other.  And even if 
the above syntax was illegal, you could still do something like:

>>> import win32com.client
>>> server = win32com.client

If you really wanted to be confusing.
msg15193 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-06-08 22:19
Logged In: YES 
user_id=357491

That line seems to have been removed from the 2.3 
documentation as of revision 1.60 but it was not backported.  
Need to find out from Martin v. Lowis whether there is a reason 
he didn't backport it.
msg15194 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-03-23 21:13
Logged In: YES 
user_id=357491

Fixed in 2.3 and 2.4 (but not in 2.2.3), so closing as out of date.
msg15195 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2004-03-23 21:13
Logged In: YES 
user_id=357491

Fixed in 2.3 and 2.4 (but not in 2.2.3), so closing as out of date.
History
Date User Action Args
2022-04-10 16:07:44adminsetgithub: 38178
2003-03-19 12:44:47amiselercreate