blob: 8e564034cf37c9464c27d6241ab81955d2dbd551 [file] [log] [blame]
Guido van Rossum4cf4de51997-09-08 04:06:15 +00001.TH PYTHON "7 September, 1997"
Guido van Rossuma7925f11994-01-26 10:20:16 +00002.SH NAME
3python \- an interpreted, interactive, object-oriented programming language
4.SH SYNOPSIS
5.B python
6[
Guido van Rossuma7925f11994-01-26 10:20:16 +00007.B \-d
8]
9[
10.B \-i
11]
12[
Guido van Rossum4cf4de51997-09-08 04:06:15 +000013.B \-O
14]
15[
16.B \-S
17]
18[
Guido van Rossumef5bca31994-05-03 14:15:32 +000019.B \-u
Guido van Rossuma7925f11994-01-26 10:20:16 +000020]
21[
22.B \-v
23]
24[
Guido van Rossum4cf4de51997-09-08 04:06:15 +000025.B \-X
26]
27.br
28 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000029.B \-c
30.I command
31|
32.I script
33|
34\-
35]
36[
37.I arguments
38]
39.SH DESCRIPTION
40Python is an interpreted, interactive, object-oriented programming
41language that combines remarkable power with very clear syntax.
42For an introduction to programming in Python you are referred to the
43Python Tutorial.
44The Python Library Reference documents built-in and standard types,
45constants, functions and modules.
46Finally, the Python Reference Manual describes the syntax and
47semantics of the core language in (perhaps too) much detail.
48.PP
49Python's basic power can be extended with your own modules written in
50C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000051On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000052Python is also adaptable as an extension language for existing
53applications.
54See the internal documentation for hints.
55.SH COMMAND LINE OPTIONS
56.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000057.B \-d
58Turn on parser debugging output (for wizards only, depending on
59compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000060.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000061.B \-i
62When a script is passed as first argument or the \fB\-c\fP option is
63used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000064command. It does not read the $PYTHONSTARTUP file. This can be
65useful to inspect global variables or a stack trace when a script
66raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000067.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000068.B \-O
69Turn on basic optimizations. This changes the filename extension for
70compiled (bytecode) files from
71.I .pyc
72to
73.I pyo.
74.TP
75.B \-S
76Disable the import of the module
77.I site
78and the site-dependent manipulations of
79.I sys.path
80that it entails.
81.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000082.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +000083Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000084.TP
85.B \-v
86Print a message each time a module is initialized, showing the place
87(filename or built-in module) from which it is loaded.
88.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000089.B \-X
90Make the standard exceptions strings instead of classes.
91Use for backward compatibility with old code only.
92.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000093.BI "\-c " command
94Specify the command to execute (see next section).
95This terminates the option list (following options are passed as
96arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +000097.SH INTERPRETER INTERFACE
98The interpreter interface resembles that of the UNIX shell: when
99called with standard input connected to a tty device, it prompts for
100commands and executes them until an EOF is read; when called with a
101file name argument or with a file as standard input, it reads and
102executes a
103.I script
104from that file;
105when called with
106.B \-c
107.I command,
108it executes the Python statement(s) given as
109.I command.
110Here
111.I command
112may contain multiple statements separated by newlines.
113Leading whitespace is significant in Python statements!
114In non-interactive mode, the entire input is parsed befored it is
115executed.
116.PP
117If available, the script name and additional arguments thereafter are
118passed to the script in the Python variable
119.I sys.argv ,
120which is a list of strings (you must first
121.I import sys
122to be able to access it).
123If no script name is given,
124.I sys.argv
125is empty; if
126.B \-c
127is used,
128.I sys.argv[0]
129contains the string
130.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000131Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000132are not placed in
133.I sys.argv.
134.PP
135In interactive mode, the primary prompt is `>>>'; the second prompt
136(which appears when a command is not complete) is `...'.
137The prompts can be changed by assignment to
138.I sys.ps1
139or
140.I sys.ps2.
141The interpreter quits when it reads an EOF at a prompt.
142When an unhandled exception occurs, a stack trace is printed and
143control returns to the primary prompt; in non-interactive mode, the
144interpreter exits after printing the stack trace.
145The interrupt signal raises the
146.I Keyboard\%Interrupt
147exception; other UNIX signals are not caught (except that SIGPIPE is
148sometimes ignored, in favor of the
149.I IOError
150exception). Error messages are written to stderr.
151.SH FILES AND DIRECTORIES
152These are subject to difference depending on local installation
153conventions:
154.IP /usr/local/bin/python
155Recommended location of the interpreter.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000156.IP /usr/local/lib/python<version>
Guido van Rossuma7925f11994-01-26 10:20:16 +0000157Recommended location of the directory containing the standard modules.
158.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000159.IP PYTHONHOME
160Change the location of the standard Python libraries. By default, the
161libraries are searched in <prefix>/lib/python<version> and
162<exec_prefix>/lib/python<version>, where <prefix> and <exec_prefix>
163are installation-dependent directories, both defaulting to
164/usr/local. When $PYTHONHOME is set to a single directory, its value
165replaces both <prefix> and <exec_prefix>. To specify different values
166for these, set $PYTHONHOME to <prefix>:<exec_prefix>.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000167.IP PYTHONPATH
168Augments the default search path for module files.
169The format is the same as the shell's $PATH: one or more directory
170pathnames separated by colons.
171Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000172The default search path is installation dependent, but generally
173begins with <prefix>/lib/python<version> (see PYTHONHOME below).
174The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000175If a script argument is given, the directory containing the script is
176inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000177The search path can be manipulated from within a Python program as the
178variable
179.I sys.path .
180.IP PYTHONSTARTUP
181If this is the name of a readable file, the Python commands in that
182file are executed before the first prompt is displayed in interactive
183mode.
184The file is executed in the same name space where interactive commands
185are executed so that objects defined or imported in it can be used
186without qualification in the interactive session.
187You can also change the prompts
188.I sys.ps1
189and
190.I sys.ps2
191in this file.
192.IP PYTHONDEBUG
193If this is set to a non-empty string it is equivalent to specifying
194the \fB\-d\fP option.
195.IP PYTHONINSPECT
196If this is set to a non-empty string it is equivalent to specifying
197the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000198.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000199If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000200the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000201.IP PYTHONVERBOSE
202If this is set to a non-empty string it is equivalent to specifying
203the \fB\-v\fP option.
204.SH SEE ALSO
205Python Tutorial
206.br
207Python Library Reference
208.br
209Python Reference Manual
Guido van Rossuma7925f11994-01-26 10:20:16 +0000210.SH AUTHOR
211.nf
212Guido van Rossum
Guido van Rossum74faed21996-07-30 19:27:05 +0000213CNRI
2141895 Preston White Drive
215Reston, VA 20191
216USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000217.PP
Guido van Rossum74faed21996-07-30 19:27:05 +0000218E-mail: guido@cnri.reston.va.us, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000219.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000220.PP
221And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000222.SH INTERNET RESOURCES
223Web site: http://www.python.org
224.br
225FTP site: ftp://ftp.python.org
226.br
227Newsgroup: comp.lang.python
Guido van Rossuma7925f11994-01-26 10:20:16 +0000228.SH COPYRIGHT
Guido van Rossum227a0a11995-01-04 19:21:21 +0000229Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
230The Netherlands.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000231.IP " "
232All Rights Reserved
233.PP
Guido van Rossum227a0a11995-01-04 19:21:21 +0000234Permission to use, copy, modify, and distribute this software and its
235documentation for any purpose and without fee is hereby granted,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000236provided that the above copyright notice appear in all copies and that
Guido van Rossum227a0a11995-01-04 19:21:21 +0000237both that copyright notice and this permission notice appear in
Guido van Rossuma7925f11994-01-26 10:20:16 +0000238supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +0000239Centrum or CWI or Corporation for National Research Initiatives or
240CNRI not be used in advertising or publicity pertaining to
241distribution of the software without specific, written prior
242permission.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000243
Guido van Rossumd266eb41996-10-25 14:44:06 +0000244While CWI is the initial source for this software, a modified version
245is made available by the Corporation for National Research Initiatives
246(CNRI) at the Internet address ftp://ftp.python.org.
247
248STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
249REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
250MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
251CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
252DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
253PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
254TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
255PERFORMANCE OF THIS SOFTWARE.