[Python-Dev] PEP 338 - Executing Modules as Scripts

Nick Coghlan ncoghlan at gmail.com
Sat Feb 11 12:04:41 CET 2006

I finally finished updating PEP 338 to comply with the flexible importing 
system in PEP 302.

The result is a not-yet-thoroughly-tested module that should allow the -m 
switch to execute any module written in Python that is accessible via an 
absolute import statement.

The PEP now uses runpy for the module name, and run_module for the function 
used to locate and execute scripts. There's probably some discussion to be had 
in relation to the Design Decisions section of the PEP, relating to the way I 
wrote the module (the handling of locals dictionaries in particular deserves 

Tracker items for the runpy module [1] and its documentation [2] are on 
Sourceforge (the interesting parts of the documentation are in the PEP, so I 
suggest reading that rather than the LaTex version).

Still missing from the first tracker item are a patch to update '-m' to invoke 
the new module and some unit tests (the version on SF has only had ad hoc 
testing from the interactive prompt at this stage). I hope to have those up 
shortly, though.


[1] http://www.python.org/sf/1429601
[2] http://www.python.org/sf/1429605
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list