[Python-Dev] Running a module as a script (original) (raw)
Nick Coghlan ncoghlan at email.com
Thu Sep 30 12:11:06 CEST 2004
- Previous message: [Python-Dev] Odd compile errors for bad genexps
- Next message: [Python-Dev] Running a module as a script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Patch # 1035498 attempts to implement the semantics suggested by Ilya and Anthony and co.
"python -m module"
Means:
find the source file for the relevant module (using the standard locations for module import)
run the located script as main (note that containing packages are NOT imported first - it's as if the relevant module was executed directly from the command line)
as with '-c' anything before the option is an argument to the interpreter, anything after is an argument to the script
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).
Special import hooks (such as zipimport) almost certainly won't work (since I don't believe they work with the current command line script mechanism).
Cheers, Nick.
-- Nick Coghlan Brisbane, Australia
- Previous message: [Python-Dev] Odd compile errors for bad genexps
- Next message: [Python-Dev] Running a module as a script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]