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/075789.html below:

[Python-Dev] Syntax suggestion for imports

[Python-Dev] Syntax suggestion for imports [Python-Dev] Syntax suggestion for importsJohn Barham jbarham at gmail.com
Thu Jan 3 02:59:19 CET 2008
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

These all look good to me.  The "short circuit" import syntax and
semantics are compact and intuitive.

> * import readline or emptymodule

This I find more problematic as "emptymodule" seems too magical.  Even
now any code that wants to use a module that might not have been
successfully imported needs to check if that's the case.  E.g., a
fuller current use-case would be:

try:
   readline = None
   import readline
except ImportError:
   pass

if readline is not None:
   readline.foo()
   ...

Conceivably emptymodule could act as a Null object but that could
create more problems than it solves.

  John
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