A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/075788.html below:

[Python-Dev] Syntax suggestion for imports

[Python-Dev] Syntax suggestion for imports [Python-Dev] Syntax suggestion for importsRaymond Hettinger python at rcn.com
Thu Jan 3 02:19:27 CET 2008
The standard library, my personal code, third-party packages, and my employer's code base are filled with examples of the following pattern:

try:
   import threading
except ImportError:
   import dummy_threading as threading

try:
    import xml.etree.cElementTree as ET
except ImportError:
    try:
        import cElementTree as ET
    except ImportError:
        import elementtree.ElementTree as ET

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

try:
    import readline
except ImportError:
    pass


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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4