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

[Python-Dev] __import__ problems

[Python-Dev] __import__ problemsMart Somermaa mrts at mrts.pri.ee
Fri Nov 28 13:59:39 CET 2008
Nick Coghlan wrote:

> As Hrvoje has pointed out, 'sys' is part of the internal interpreter
> machinery - it's there as soon as the interpreter starts. The import
> call for it just grabs it out of the module cache and creates a
> reference to it in the current namespace.
I understand that, but

Explicit is better than implicit.

 --> non-explicit import sys and __import__(modname) to access

     sys.modules[modname]

Simple is better than complex.

 --> three lines for a common use case instead of one

Readability counts.

 --> why is sys imported in this WSGI app (that shouldn't generally

     touch any of the common sys.argv, sys.stdout etc)?!

     (500 lines later) aha, to access sys.modules

There should be one-- and preferably only one --obvious way to do it.

--> should I use the 3-line idiom? should I use the getattr() idiom?

    Ideally, __import__() should support the only obvious way.

In short, the three-line version doesn't convey the intent in an obvious way and does more work than is necessary.

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