1PYTHON(1)                   General Commands Manual                  PYTHON(1)
2
3
4

NAME

6       python  - an interpreted, interactive, object-oriented programming lan‐
7       guage
8

SYNOPSIS

10       python [ -B ] [ -d ] [ -E ] [ -h ] [ -i ] [ -m module-name ]
11              [ -O ] [ -O0 ] [ -Q argument ] [ -s ] [ -S ] [ -t ] [ -u ]
12              [ -v ] [ -V ] [ -W argument ] [ -x ] [ -3 ] [ -?  ]
13              [ -c command | script | - ] [ arguments ]
14

DESCRIPTION

16       Python is an interpreted, interactive, object-oriented programming lan‐
17       guage  that  combines  remarkable power with very clear syntax.  For an
18       introduction to programming in Python you are referred  to  the  Python
19       Tutorial.  The Python Library Reference documents built-in and standard
20       types, constants, functions and modules.  Finally, the Python Reference
21       Manual describes the syntax and semantics of the core language in (per‐
22       haps too) much detail.  (These documents may be located via the  INTER‐
23       NET RESOURCES below; they may be installed on your system as well.)
24
25       Python's basic power can be extended with your own modules written in C
26       or C++.  On most  systems  such  modules  may  be  dynamically  loaded.
27       Python is also adaptable as an extension language for existing applica‐
28       tions.  See the internal documentation for hints.
29
30       Documentation for installed Python modules and packages can  be  viewed
31       by running the pydoc program.
32

COMMAND LINE OPTIONS

34       -B     Don't  write  .py[co] files on import. See also PYTHONDONTWRITE‐
35              BYTECODE.
36
37       -c command
38              Specify the command to execute (see next section).  This  termi‐
39              nates the option list (following options are passed as arguments
40              to the command).
41
42       -d     Turn on parser debugging output (for wizards only, depending  on
43              compilation options).
44
45       -E     Ignore environment variables like PYTHONPATH and PYTHONHOME that
46              modify the behavior of the interpreter.
47
48       -h ,  -? ,  --help
49              Prints the usage for the interpreter executable and exits.
50
51       -i     When a script is passed as first argument or the  -c  option  is
52              used,  enter  interactive mode after executing the script or the
53              command.  It does not read the $PYTHONSTARTUP file.  This can be
54              useful  to  inspect  global  variables  or  a stack trace when a
55              script raises an exception.
56
57       -m module-name
58              Searches sys.path for the named module and runs the  correspond‐
59              ing .py file as a script.
60
61       -O     Turn  on  basic optimizations.  This changes the filename exten‐
62              sion for compiled (bytecode) files from  .pyc  to  .pyo.   Given
63              twice, causes docstrings to be discarded.
64
65       -O0    Discard docstrings in addition to the -O optimizations.
66
67       -Q argument
68              Division  control;  see  PEP  238.   The argument must be one of
69              "old" (the default, int/int  and  long/long  return  an  int  or
70              long), "new" (new division semantics, i.e. int/int and long/long
71              returns a float), "warn" (old division semantics with a  warning
72              for int/int and long/long), or "warnall" (old division semantics
73              with a warning for all use of the division operator).  For a use
74              of "warnall", see the Tools/scripts/fixdiv.py script.
75
76       -s     Don't add user site directory to sys.path.
77
78       -S     Disable  the  import  of  the module site and the site-dependent
79              manipulations of sys.path that it entails.
80
81       -t     Issue a warning when a source file mixes  tabs  and  spaces  for
82              indentation  in a way that makes it depend on the worth of a tab
83              expressed in spaces.  Issue an error when the  option  is  given
84              twice.
85
86       -u     Force  stdin,  stdout  and  stderr to be totally unbuffered.  On
87              systems where it matters, also put stdin, stdout and  stderr  in
88              binary  mode.   Note  that there is internal buffering in xread‐
89              lines(), readlines() and file-object  iterators  ("for  line  in
90              sys.stdin")  which  is  not  influenced by this option.  To work
91              around this, you will want to use "sys.stdin.readline()"  inside
92              a "while 1:" loop.
93
94       -v     Print  a  message each time a module is initialized, showing the
95              place (filename or built-in module) from  which  it  is  loaded.
96              When  given twice, print a message for each file that is checked
97              for when searching for a module.  Also provides  information  on
98              module cleanup at exit.
99
100       -V ,  --version
101              Prints the Python version number of the executable and exits.
102
103       -W argument
104              Warning  control.   Python  sometimes  prints warning message to
105              sys.stderr.  A typical warning message has the  following  form:
106              file:line:  category:  message.   By  default,  each  warning is
107              printed once for each source line where it occurs.  This  option
108              controls  how  often  warnings are printed.  Multiple -W options
109              may be given; when a warning matches more than one  option,  the
110              action  for  the  last matching option is performed.  Invalid -W
111              options are ignored (a warning message is printed about  invalid
112              options when the first warning is issued).  Warnings can also be
113              controlled from within a Python program using the warnings  mod‐
114              ule.
115
116              The  simplest  form  of  argument is one of the following action
117              strings (or a unique abbreviation): ignore to ignore  all  warn‐
118              ings; default to explicitly request the default behavior (print‐
119              ing each warning once per source line); all to print  a  warning
120              each  time it occurs (this may generate many messages if a warn‐
121              ing is triggered repeatedly for the same source  line,  such  as
122              inside a loop); module to print each warning only the first time
123              it occurs in each module; once to print each  warning  only  the
124              first time it occurs in the program; or error to raise an excep‐
125              tion instead of printing a warning message.
126
127              The  full  form  of  argument  is   action:message:category:mod‐
128              ule:line.   Here,  action is as explained above but only applies
129              to messages that match the remaining fields.  Empty fields match
130              all  values;  trailing empty fields may be omitted.  The message
131              field matches the start of the  warning  message  printed;  this
132              match is case-insensitive.  The category field matches the warn‐
133              ing category.  This must be a class name; the match test whether
134              the  actual warning category of the message is a subclass of the
135              specified warning category.  The full class name must be  given.
136              The module field matches the (fully-qualified) module name; this
137              match is case-sensitive.  The line field matches the  line  num‐
138              ber,  where zero matches all line numbers and is thus equivalent
139              to an omitted line number.
140
141       -x     Skip the first line of the source.  This is intended for  a  DOS
142              specific hack only.  Warning: the line numbers in error messages
143              will be off by one!
144
145       -3     Warn about Python 3.x incompatibilities that 2to3  cannot  triv‐
146              ially fix.
147

INTERPRETER INTERFACE

149       The interpreter interface resembles that of the UNIX shell: when called
150       with standard input connected to a tty device, it prompts for  commands
151       and  executes  them  until an EOF is read; when called with a file name
152       argument or with a file as standard input,  it  reads  and  executes  a
153       script  from  that  file;  when called with -c command, it executes the
154       Python statement(s) given as command.  Here command may contain  multi‐
155       ple  statements  separated by newlines.  Leading whitespace is signifi‐
156       cant in Python statements!  In non-interactive mode, the  entire  input
157       is parsed before it is executed.
158
159       If  available,  the script name and additional arguments thereafter are
160       passed to the script in the Python variable sys.argv , which is a  list
161       of  strings (you must first import sys to be able to access it).  If no
162       script name is given, sys.argv[0] is an empty string; if  -c  is  used,
163       sys.argv[0] contains the string '-c'.  Note that options interpreted by
164       the Python interpreter itself are not placed in sys.argv.
165
166       In interactive mode, the primary prompt is  `>>>';  the  second  prompt
167       (which  appears  when a command is not complete) is `...'.  The prompts
168       can be changed by assignment to sys.ps1 or  sys.ps2.   The  interpreter
169       quits  when  it  reads an EOF at a prompt.  When an unhandled exception
170       occurs, a stack trace is printed and control  returns  to  the  primary
171       prompt;  in  non-interactive mode, the interpreter exits after printing
172       the stack trace.  The interrupt  signal  raises  the  KeyboardInterrupt
173       exception;  other  UNIX  signals are not caught (except that SIGPIPE is
174       sometimes ignored, in favor of the IOError exception).  Error  messages
175       are written to stderr.
176

FILES AND DIRECTORIES

178       These are subject to difference depending on local installation conven‐
179       tions; ${prefix}  and  ${exec_prefix}  are  installation-dependent  and
180       should  be  interpreted as for GNU software; they may be the same.  The
181       default for both is /usr/local.
182
183       ${exec_prefix}/bin/python
184              Recommended location of the interpreter.
185
186       ${prefix}/lib/python<version>
187       ${exec_prefix}/lib/python<version>
188              Recommended locations of the directories containing the standard
189              modules.
190
191       ${prefix}/include/python<version>
192       ${exec_prefix}/include/python<version>
193              Recommended  locations of the directories containing the include
194              files needed for developing Python extensions and embedding  the
195              interpreter.
196
197       ~/.pythonrc.py
198              User-specific initialization file loaded by the user module; not
199              used by default or by most applications.
200

ENVIRONMENT VARIABLES

202       PYTHONHOME
203              Change the  location  of  the  standard  Python  libraries.   By
204              default, the libraries are searched in ${prefix}/lib/python<ver‐
205              sion> and  ${exec_prefix}/lib/python<version>,  where  ${prefix}
206              and  ${exec_prefix} are installation-dependent directories, both
207              defaulting to /usr/local.  When $PYTHONHOME is set to  a  single
208              directory, its value replaces both ${prefix} and ${exec_prefix}.
209              To specify different values for these, set $PYTHONHOME to ${pre‐
210              fix}:${exec_prefix}.
211
212       PYTHONPATH
213              Augments  the  default search path for module files.  The format
214              is the same as the shell's $PATH: one or  more  directory  path‐
215              names   separated   by  colons.   Non-existent  directories  are
216              silently ignored.   The  default  search  path  is  installation
217              dependent,  but  generally begins with ${prefix}/lib/python<ver‐
218              sion> (see PYTHONHOME above).  The default search path is always
219              appended  to  $PYTHONPATH.   If  a script argument is given, the
220              directory containing the script is inserted in the path in front
221              of  $PYTHONPATH.  The search path can be manipulated from within
222              a Python program as the variable sys.path .
223
224       PYTHONSTARTUP
225              If this is the name of a readable file, the Python  commands  in
226              that  file  are executed before the first prompt is displayed in
227              interactive mode.  The file is executed in the same  name  space
228              where  interactive commands are executed so that objects defined
229              or imported in it can  be  used  without  qualification  in  the
230              interactive  session.   You  can also change the prompts sys.ps1
231              and sys.ps2 in this file.
232
233       PYTHONY2K
234              Set this to a non-empty string  to  cause  the  time  module  to
235              require  dates  specified  as  strings to include 4-digit years,
236              otherwise 2-digit years are converted based on  rules  described
237              in the time module documentation.
238
239       PYTHONOPTIMIZE
240              If  this is set to a non-empty string it is equivalent to speci‐
241              fying the -O option. If set to an integer, it is  equivalent  to
242              specifying -O multiple times.
243
244       PYTHONDEBUG
245              If  this is set to a non-empty string it is equivalent to speci‐
246              fying the -d option. If set to an integer, it is  equivalent  to
247              specifying -d multiple times.
248
249       PYTHONDONTWRITEBYTECODE
250              If  this is set to a non-empty string it is equivalent to speci‐
251              fying the -B option (don't try to write .py[co] files).
252
253       PYTHONINSPECT
254              If this is set to a non-empty string it is equivalent to  speci‐
255              fying the -i option.
256
257       PYTHONNOUSERSITE
258              If  this is set to a non-empty string it is equivalent to speci‐
259              fying the -s option  (Don't  add  the  user  site  directory  to
260              sys.path).
261
262       PYTHONUNBUFFERED
263              If  this is set to a non-empty string it is equivalent to speci‐
264              fying the -u option.
265
266       PYTHONVERBOSE
267              If this is set to a non-empty string it is equivalent to  speci‐
268              fying  the  -v option. If set to an integer, it is equivalent to
269              specifying -v multiple times.
270
271       PYTHONWARNINGS
272              If this is set to a comma-separated string it is  equivalent  to
273              specifying the -W option for each separate value.
274

AUTHOR

276       The Python Software Foundation: http://www.python.org/psf
277

INTERNET RESOURCES

279       Main website:  http://www.python.org/
280       Documentation:  http://docs.python.org/
281       Developer resources:  http://www.python.org/dev/
282       Downloads:  http://python.org/download/
283       Module repository:  http://pypi.python.org/
284       Newsgroups:  comp.lang.python, comp.lang.python.announce
285

LICENSING

287       Python  is  distributed  under  an  Open  Source license.  See the file
288       "LICENSE" in the Python source distribution for information on terms  &
289       conditions  for  accessing  and  otherwise  using Python and for a DIS‐
290       CLAIMER OF ALL WARRANTIES.
291
292
293
294             $Date: 2010-04-06 18:38:57 -0500 (Tue, 06 Apr 2010) $   PYTHON(1)
Impressum