summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-10-07 06:46:25 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-10-07 06:46:25 (GMT)
commitdb29e0fe8cab58c68d1263487ba5bac7b99c7612 (patch)
tree8ca6ad43fa5c3b9878ccf022f7161be0b6ba8b5e /Doc
parentfb09f0e85cd75ec46700562687a9da3063ff0b7c (diff)
downloadcpython-db29e0fe8cab58c68d1263487ba5bac7b99c7612.zip
cpython-db29e0fe8cab58c68d1263487ba5bac7b99c7612.tar.gz
cpython-db29e0fe8cab58c68d1263487ba5bac7b99c7612.tar.bz2
SF patch #1035498: -m option to run a module as a script
(Contributed by Nick Coghlan.)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tut/tut.tex13
1 files changed, 10 insertions, 3 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index 9cb665a..ba0e3fd 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -205,6 +205,11 @@ executes the statement(s) in \var{command}, analogous to the shell's
or other characters that are special to the shell, it is best to quote
\var{command} in its entirety with double quotes.
+Some Python modules are also useful as scripts. These can be invoked using
+\samp{\program{python} \programopt{-m} \var{module} [arg] ...}, which
+executes the source file for \var{module} as if you had spelled out its
+full name on the command line.
+
Note that there is a difference between \samp{python file} and
\samp{python <file}. In the latter case, input requests from the
program, such as calls to \function{input()} and \function{raw_input()}, are
@@ -229,9 +234,11 @@ one; when no script and no arguments are given, \code{sys.argv[0]} is
an empty string. When the script name is given as \code{'-'} (meaning
standard input), \code{sys.argv[0]} is set to \code{'-'}. When
\programopt{-c} \var{command} is used, \code{sys.argv[0]} is set to
-\code{'-c'}. Options found after \programopt{-c} \var{command} are
-not consumed by the Python interpreter's option processing but left in
-\code{sys.argv} for the command to handle.
+\code{'-c'}. When \programopt{-m} \var{module} is used, \code{sys.argv[0]}
+is set to the full name of the located module. Options found after
+\programopt{-c} \var{command} or \programopt{-m} \var{module} are not consumed
+by the Python interpreter's option processing but left in \code{sys.argv} for
+the command or module to handle.
\subsection{Interactive Mode \label{interactive}}