summaryrefslogtreecommitdiffstats
path: root/Doc/using/cmdline.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/using/cmdline.rst')
-rw-r--r--Doc/using/cmdline.rst68
1 files changed, 34 insertions, 34 deletions
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index b3a44aa..643464b 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -8,8 +8,8 @@ Command line and environment
The CPython interpreter scans the command line and the environment for various
settings.
-.. note::
-
+.. note::
+
Other implementations' command line schemes may differ. See
:ref:`implementations` for further resources.
@@ -61,7 +61,7 @@ source.
Execute the Python code in *command*. *command* can be one ore more
statements separated by newlines, with significant leading whitespace as in
normal module code.
-
+
If this option is given, the first element of :data:`sys.argv` will be
``"-c"`` and the current directory will be added to the start of
:data:`sys.path` (allowing modules in that directory to be imported as top
@@ -72,7 +72,7 @@ source.
Search :data:`sys.path` for the named module and execute its contents as
the :mod:`__main__` module.
-
+
Since the argument is a *module* name, you must not give a file extension
(``.py``). The ``module-name`` should be a valid Python module name, but
the implementation may not always enforce this (e.g. it may allow you to
@@ -84,18 +84,18 @@ source.
written in C, since they do not have Python module files. However, it
can still be used for precompiled modules, even if the original source
file is not available.
-
+
If this option is given, the first element of :data:`sys.argv` will be the
full path to the module file. As with the :option:`-c` option, the current
directory will be added to the start of :data:`sys.path`.
-
+
Many standard library modules contain code that is invoked on their execution
as a script. An example is the :mod:`timeit` module::
python -mtimeit -s 'setup here' 'benchmarked code here'
python -mtimeit -h # for details
- .. seealso::
+ .. seealso::
:func:`runpy.run_module`
The actual implementation of this feature.
@@ -163,7 +163,7 @@ Generic options
--version
Print the Python version number and exit. Example output could be::
-
+
Python 2.5.1
.. versionchanged:: 2.5
@@ -201,7 +201,7 @@ Miscellaneous options
enter interactive mode after executing the script or the command, even when
:data:`sys.stdin` does not appear to be a terminal. The
:envvar:`PYTHONSTARTUP` file is not read.
-
+
This can be useful to inspect global variables or a stack trace when a script
raises an exception. See also :envvar:`PYTHONINSPECT`.
@@ -221,7 +221,7 @@ Miscellaneous options
.. cmdoption:: -Q <arg>
Division control. The argument must be one of the following:
-
+
``old``
division of int/int and long/long return an int or long (*default*)
``new``
@@ -264,10 +264,10 @@ Miscellaneous options
.. cmdoption:: -u
-
+
Force stdin, stdout and stderr to be totally unbuffered. On systems where it
matters, also put stdin, stdout and stderr in binary mode.
-
+
Note that there is internal buffering in :meth:`file.readlines` and
:ref:`bltin-file-objects` (``for line in sys.stdin``) which is not influenced
by this option. To work around this, you will want to use
@@ -279,7 +279,7 @@ Miscellaneous options
.. XXX should the -U option be documented?
.. cmdoption:: -v
-
+
Print a message each time a module is initialized, showing the place
(filename or built-in module) from which it is loaded. When given twice
(:option:`-vv`), print a message for each file that is checked for when
@@ -288,13 +288,13 @@ Miscellaneous options
.. cmdoption:: -W arg
-
+
Warning control. Python's warning machinery by default prints warning
messages to :data:`sys.stderr`. A typical warning message has the following
form::
file:line: category: message
-
+
By default, each warning is printed once for each source line where it
occurs. This option controls how often warnings are printed.
@@ -302,13 +302,13 @@ Miscellaneous options
one option, the action for the last matching option is performed. Invalid
:option:`-W` options are ignored (though, a warning message is printed about
invalid options when the first warning is issued).
-
+
Warnings can also be controlled from within a Python program using the
:mod:`warnings` module.
The simplest form of argument is one of the following action strings (or a
unique abbreviation):
-
+
``ignore``
Ignore all warnings.
``default``
@@ -324,9 +324,9 @@ Miscellaneous options
Print each warning only the first time it occurs in the program.
``error``
Raise an exception instead of printing a warning message.
-
- The full form of argument is::
-
+
+ The full form of argument is::
+
action:message:category:module:line
Here, *action* is as explained above but only applies to messages that match
@@ -347,10 +347,10 @@ Miscellaneous options
.. cmdoption:: -x
-
+
Skip the first line of the source, allowing use of non-Unix forms of
``#!cmd``. This is intended for a DOS specific hack only.
-
+
.. warning:: The line numbers in error messages will be off by one!
@@ -380,13 +380,13 @@ Environment variables
These environment variables influence Python's behavior.
.. envvar:: PYTHONHOME
-
+
Change the location of the standard Python libraries. By default, the
libraries are searched in :file:`{prefix}/lib/python{version}` and
:file:`{exec_prefix}/lib/python{version}`, where :file:`{prefix}` and
:file:`{exec_prefix}` are installation-dependent directories, both defaulting
to :file:`/usr/local`.
-
+
When :envvar:`PYTHONHOME` is set to a single directory, its value replaces
both :file:`{prefix}` and :file:`{exec_prefix}`. To specify different values
for these, set :envvar:`PYTHONHOME` to :file:`{prefix}:{exec_prefix}`.
@@ -402,11 +402,11 @@ These environment variables influence Python's behavior.
In addition to normal directories, individual :envvar:`PYTHONPATH` entries
may refer to zipfiles containing pure Python modules (in either source or
compiled form). Extension modules cannot be imported from zipfiles.
-
+
The default search path is installation dependent, but generally begins with
:file:`{prefix}/lib/python{version}` (see :envvar:`PYTHONHOME` above). It
is *always* appended to :envvar:`PYTHONPATH`.
-
+
An additional directory will be inserted in the search path in front of
:envvar:`PYTHONPATH` as described above under
:ref:`using-on-interface-options`. The search path can be manipulated from
@@ -414,7 +414,7 @@ These environment variables influence Python's behavior.
.. envvar:: PYTHONSTARTUP
-
+
If this is the name of a readable file, the Python commands in that file are
executed before the first prompt is displayed in interactive mode. The file
is executed in the same namespace where interactive commands are executed so
@@ -424,7 +424,7 @@ These environment variables influence Python's behavior.
.. envvar:: PYTHONY2K
-
+
Set this to a non-empty string to cause the :mod:`time` module to require
dates specified as strings to include 4-digit years, otherwise 2-digit years
are converted based on rules described in the :mod:`time` module
@@ -432,21 +432,21 @@ These environment variables influence Python's behavior.
.. envvar:: PYTHONOPTIMIZE
-
+
If this is set to a non-empty string it is equivalent to specifying the
:option:`-O` option. If set to an integer, it is equivalent to specifying
:option:`-O` multiple times.
.. envvar:: PYTHONDEBUG
-
+
If this is set to a non-empty string it is equivalent to specifying the
:option:`-d` option. If set to an integer, it is equivalent to specifying
:option:`-d` multiple times.
.. envvar:: PYTHONINSPECT
-
+
If this is set to a non-empty string it is equivalent to specifying the
:option:`-i` option.
@@ -455,20 +455,20 @@ These environment variables influence Python's behavior.
.. envvar:: PYTHONUNBUFFERED
-
+
If this is set to a non-empty string it is equivalent to specifying the
:option:`-u` option.
.. envvar:: PYTHONVERBOSE
-
+
If this is set to a non-empty string it is equivalent to specifying the
:option:`-v` option. If set to an integer, it is equivalent to specifying
:option:`-v` multiple times.
.. envvar:: PYTHONCASEOK
-
+
If this is set, Python ignores case in :keyword:`import` statements. This
only works on Windows.