Raymond Hettinger wrote:
 > How about a new, simpler syntax:
> 
> * import threading or dummy_threading as threading
> 
> * import xml.etree.CElementTree or cElementTree or elementree.ElementTree as 
> ET
> 
> * from cStringIO or StringIO import StringIO
> 
> * import readline or emptymodule

The syntax idea has a nice ring to it, except for the last idea. As
others have already said, the name emptymodule is too magic.

The readline example becomes more readable when you change the import to

import readline or None as readline


In my opinion the import or as syntax definition is easy to understand
if you force the user to always have an "as" statement. The None name is
optional but must be the last name:

import name[, or name2[, or name3 ...] [, or None] as target

This translates into:

try:
    import name as target
except ImportError:
    try:
        import name2 as target
    except ImportError:
        target = None

from name[, or name2 ...] [, or None] import target

translates into

try:
    from name import target
except ImportError:
    try:
        from name2 import target
    except ImportError:
        target = None

Christian
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to