[Python-ideas] breaking out of module execution

Jim Jewett jimjjewett at gmail.com
Thu Apr 26 02:04:25 CEST 2012

On Tue, Apr 24, 2012 at 8:55 PM, Steven D'Aprano <steve at pearwood.info> wrote:

> - encourages or requires duplicate code and copy-and-paste programming

How does stopping a module definition early encourage duplicate code?
Just because you might have to react differently after a full import
vs a partial?

> Today, if you successfully import a module, you know that all the top-level
> code in that module was executed.

No, you don't.

On the other hand, the counterexamples (circular imports, some lazy
imports, module-name clashes, top-level definitions dependent on what
was already imported by other modules, etc) are already painful to


More information about the Python-ideas mailing list