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 ] [ -u ]
12              [ -v ] [ -V ] [ -W argument ] [ -x ] [ -?  ]
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       -u     Force stdin, stdout and stderr to  be  totally  unbuffered.   On
82              systems  where  it matters, also put stdin, stdout and stderr in
83              binary mode.  Note that there is  internal  buffering  in  read‐
84              lines()  and  file-object  iterators  ("for  line in sys.stdin")
85              which is not influenced by this option.  To  work  around  this,
86              you  will want to use "sys.stdin.readline()" inside a "while 1:"
87              loop.
88
89       -v     Print a message each time a module is initialized,  showing  the
90              place  (filename  or  built-in  module) from which it is loaded.
91              When given twice, print a message for each file that is  checked
92              for  when  searching for a module.  Also provides information on
93              module cleanup at exit.
94
95       -V ,  --version
96              Prints the Python version number of the executable and exits.
97
98       -W argument
99              Warning control.  Python sometimes  prints  warning  message  to
100              sys.stderr.   A  typical warning message has the following form:
101              file:line: category:  message.   By  default,  each  warning  is
102              printed  once for each source line where it occurs.  This option
103              controls how often warnings are printed.   Multiple  -W  options
104              may  be  given; when a warning matches more than one option, the
105              action for the last matching option is  performed.   Invalid  -W
106              options  are ignored (a warning message is printed about invalid
107              options when the first warning is issued).  Warnings can also be
108              controlled  from within a Python program using the warnings mod‐
109              ule.
110
111              The simplest form of argument is one  of  the  following  action
112              strings  (or  a unique abbreviation): ignore to ignore all warn‐
113              ings; default to explicitly request the default behavior (print‐
114              ing  each  warning once per source line); all to print a warning
115              each time it occurs (this may generate many messages if a  warn‐
116              ing  is  triggered  repeatedly for the same source line, such as
117              inside a loop); module to print each warning only the first time
118              it  occurs  in  each module; once to print each warning only the
119              first time it occurs in the program; or error to raise an excep‐
120              tion instead of printing a warning message.
121
122              The   full  form  of  argument  is  action:message:category:mod‐
123              ule:line.  Here, action is as explained above but  only  applies
124              to messages that match the remaining fields.  Empty fields match
125              all values; trailing empty fields may be omitted.   The  message
126              field  matches  the  start  of the warning message printed; this
127              match is case-insensitive.  The category field matches the warn‐
128              ing category.  This must be a class name; the match test whether
129              the actual warning category of the message is a subclass of  the
130              specified  warning category.  The full class name must be given.
131              The module field matches the (fully-qualified) module name; this
132              match  is  case-sensitive.  The line field matches the line num‐
133              ber, where zero matches all line numbers and is thus  equivalent
134              to an omitted line number.
135
136       -x     Skip  the  first line of the source.  This is intended for a DOS
137              specific hack only.  Warning: the line numbers in error messages
138              will be off by one!
139

INTERPRETER INTERFACE

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

FILES AND DIRECTORIES

170       These are subject to difference depending on local installation conven‐
171       tions; ${prefix}  and  ${exec_prefix}  are  installation-dependent  and
172       should  be  interpreted as for GNU software; they may be the same.  The
173       default for both is /usr/local.
174
175       ${exec_prefix}/bin/python
176              Recommended location of the interpreter.
177
178       ${prefix}/lib/python<version>
179       ${exec_prefix}/lib/python<version>
180              Recommended locations of the directories containing the standard
181              modules.
182
183       ${prefix}/include/python<version>
184       ${exec_prefix}/include/python<version>
185              Recommended  locations of the directories containing the include
186              files needed for developing Python extensions and embedding  the
187              interpreter.
188

ENVIRONMENT VARIABLES

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

AUTHOR

260       The Python Software Foundation: http://www.python.org/psf
261

INTERNET RESOURCES

263       Main website:  http://www.python.org/
264       Documentation:  http://docs.python.org/py3k/
265       Developer resources:  http://www.python.org/dev/
266       Downloads:  http://python.org/download/
267       Module repository:  http://pypi.python.org/
268       Newsgroups:  comp.lang.python, comp.lang.python.announce
269

LICENSING

271       Python  is  distributed  under  an  Open  Source license.  See the file
272       "LICENSE" in the Python source distribution for information on terms  &
273       conditions  for  accessing  and  otherwise  using Python and for a DIS‐
274       CLAIMER OF ALL WARRANTIES.
275
276
277
278             $Date: 2010-01-31 10:17:23 -0600 (Sun, 31 Jan 2010) $   PYTHON(1)
Impressum