[Python-Dev] Syntax suggestion for imports
Aahz
aahz at pythoncraft.com
Thu Jan 3 03:08:25 CET 2008
On Wed, Jan 02, 2008, Raymond Hettinger wrote:
>
> 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
>
> How about a new, simpler syntax:
>
> * import threading or dummy_threading as threading
My gut reaction is -0. For starters, many of these should go away with
Python 3.0 (e.g. cStringIO). Also, annoying as the try/except is, I
think the fact that it signals the special import is helpful; your
suggestion is too light-weight IMO. If you could devise something just
a bit heavier, that would be much better.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Weinberg's Second Law: If builders built buildings the way programmers wrote
programs, then the first woodpecker that came along would destroy civilization.
More information about the Python-Dev
mailing list