[Python-Dev] Running a module as a script
Phillip J. Eby
pje at telecommunity.com
Thu Sep 30 17:16:12 CEST 2004
At 04:31 PM 9/30/04 +0200, Thomas Heller wrote:
>Aahz <aahz at pythoncraft.com> writes:
> > On Thu, Sep 30, 2004, Nick Coghlan wrote:
> >> The allowed modules are those whose associated source file meet the
> >> normal rules for a command line script. I believe that means .py
> >> and .pyc files only (e.g. "python -m profile" works, but "python -m
> >> hotshot" does not).
> > Not positive, but if you're allowing .pyc, you should probably allow
> > .pyo if optimize mode is on.
>Plus .pyw, on Windows.
Using the C equivalent of 'imp.find_module()' should cover all these cases,
and any new forms of PY_SOURCE or PY_COMPILED that come up in future.
More information about the Python-Dev