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

INTERPRETER INTERFACE

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

FILES AND DIRECTORIES

166       These are subject to difference depending on local installation conven‐
167       tions; ${prefix}  and  ${exec_prefix}  are  installation-dependent  and
168       should  be  interpreted as for GNU software; they may be the same.  The
169       default for both is /usr/local.
170
171       ${exec_prefix}/bin/python
172              Recommended location of the interpreter.
173
174       ${prefix}/lib/python<version>
175       ${exec_prefix}/lib/python<version>
176              Recommended locations of the directories containing the standard
177              modules.
178
179       ${prefix}/include/python<version>
180       ${exec_prefix}/include/python<version>
181              Recommended  locations of the directories containing the include
182              files needed for developing Python extensions and embedding  the
183              interpreter.
184
185       ~/.pythonrc.py
186              User-specific initialization file loaded by the user module; not
187              used by default or by most applications.
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       PYTHONINSPECT
238              If  this is set to a non-empty string it is equivalent to speci‐
239              fying the -i option.
240
241       PYTHONUNBUFFERED
242              If this is set to a non-empty string it is equivalent to  speci‐
243              fying the -u option.
244
245       PYTHONVERBOSE
246              If  this is set to a non-empty string it is equivalent to speci‐
247              fying the -v option. If set to an integer, it is  equivalent  to
248              specifying -v multiple times.
249

AUTHOR

251       The Python Software Foundation: http://www.python.org/psf
252

INTERNET RESOURCES

254       Main website:  http://www.python.org/
255       Documentation:  http://docs.python.org/
256       Community website:  http://starship.python.net/
257       Developer resources:  http://www.python.org/dev/
258       FTP:  ftp://ftp.python.org/pub/python/
259       Module repository:  http://www.vex.net/parnassus/
260       Newsgroups:  comp.lang.python, comp.lang.python.announce
261

LICENSING

263       Python  is  distributed  under  an  Open  Source license.  See the file
264       "LICENSE" in the Python source distribution for information on terms  &
265       conditions  for  accessing  and  otherwise  using Python and for a DIS‐
266       CLAIMER OF ALL WARRANTIES.
267
268
269
270             $Date: 2005-03-21 01:16:03 +1100 (Mon, 21 Mar 2005) $   PYTHON(1)
Impressum