blob: 4e7d46a767f5a9abae70fcb65b31c671d8aab822 [file] [log] [blame]
Guido van Rossum227a0a11995-01-04 19:21:21 +00001.TH PYTHON "4 January 1995"
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[
7.I X11-options
8]
9[
10.B \-d
11]
12[
13.B \-i
14]
15[
Guido van Rossum36a37341994-05-30 13:41:15 +000016.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[
25.B \-c
26.I command
27|
28.I script
29|
30\-
31]
32[
33.I arguments
34]
35.SH DESCRIPTION
36Python is an interpreted, interactive, object-oriented programming
37language that combines remarkable power with very clear syntax.
38For an introduction to programming in Python you are referred to the
39Python Tutorial.
40The Python Library Reference documents built-in and standard types,
41constants, functions and modules.
42Finally, the Python Reference Manual describes the syntax and
43semantics of the core language in (perhaps too) much detail.
44.PP
45Python's basic power can be extended with your own modules written in
46C or C++.
47On some (most?) systems such modules may be dynamically loaded.
48Python is also adaptable as an extension language for existing
49applications.
50See the internal documentation for hints.
51.SH COMMAND LINE OPTIONS
52.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000053.B \-d
54Turn on parser debugging output (for wizards only, depending on
55compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000056.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000057.B \-i
58When a script is passed as first argument or the \fB\-c\fP option is
59used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000060command. It does not read the $PYTHONSTARTUP file. This can be
61useful to inspect global variables or a stack trace when a script
62raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000063.TP
Guido van Rossum36a37341994-05-30 13:41:15 +000064.B \-s
65Suppresses the automatic printing of expressions entered in
66interactive mode (useful when input is actually generated e.g. by
67Emacs).
68.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000069.B \-u
70Force stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000071.TP
72.B \-v
73Print a message each time a module is initialized, showing the place
74(filename or built-in module) from which it is loaded.
75.TP
76.BI "\-c " command
77Specify the command to execute (see next section).
78This terminates the option list (following options are passed as
79arguments to the command).
80.PP
81When the interpreter is configured to contain the
82.I stdwin
83built-in module for use with the X window system, additional command
84line options common to most X applications are recognized (by STDWIN),
85e.g.
86.B \-display
87.I displayname
88and
89.B \-geometry
90.I widthxheight+x+y.
91The complete set of options is described in the STDWIN documentation.
92.SH INTERPRETER INTERFACE
93The interpreter interface resembles that of the UNIX shell: when
94called with standard input connected to a tty device, it prompts for
95commands and executes them until an EOF is read; when called with a
96file name argument or with a file as standard input, it reads and
97executes a
98.I script
99from that file;
100when called with
101.B \-c
102.I command,
103it executes the Python statement(s) given as
104.I command.
105Here
106.I command
107may contain multiple statements separated by newlines.
108Leading whitespace is significant in Python statements!
109In non-interactive mode, the entire input is parsed befored it is
110executed.
111.PP
112If available, the script name and additional arguments thereafter are
113passed to the script in the Python variable
114.I sys.argv ,
115which is a list of strings (you must first
116.I import sys
117to be able to access it).
118If no script name is given,
119.I sys.argv
120is empty; if
121.B \-c
122is used,
123.I sys.argv[0]
124contains the string
125.I '-c'.
126Note that options interpreter by the Python interpreter or by STDWIN
127are not placed in
128.I sys.argv.
129.PP
130In interactive mode, the primary prompt is `>>>'; the second prompt
131(which appears when a command is not complete) is `...'.
132The prompts can be changed by assignment to
133.I sys.ps1
134or
135.I sys.ps2.
136The interpreter quits when it reads an EOF at a prompt.
137When an unhandled exception occurs, a stack trace is printed and
138control returns to the primary prompt; in non-interactive mode, the
139interpreter exits after printing the stack trace.
140The interrupt signal raises the
141.I Keyboard\%Interrupt
142exception; other UNIX signals are not caught (except that SIGPIPE is
143sometimes ignored, in favor of the
144.I IOError
145exception). Error messages are written to stderr.
146.SH FILES AND DIRECTORIES
147These are subject to difference depending on local installation
148conventions:
149.IP /usr/local/bin/python
150Recommended location of the interpreter.
151.IP /usr/local/lib/python
152Recommended location of the directory containing the standard modules.
153.SH ENVIRONMENT VARIABLES
154.IP PYTHONPATH
155Augments the default search path for module files.
156The format is the same as the shell's $PATH: one or more directory
157pathnames separated by colons.
158Non-existant directories are silently ignored.
159The default search path is installation dependent, but always begins
160with `.', (for example,
161.I .:/usr/local/lib/python ).
162The default search path is appended to $PYTHONPATH.
163The search path can be manipulated from within a Python program as the
164variable
165.I sys.path .
166.IP PYTHONSTARTUP
167If this is the name of a readable file, the Python commands in that
168file are executed before the first prompt is displayed in interactive
169mode.
170The file is executed in the same name space where interactive commands
171are executed so that objects defined or imported in it can be used
172without qualification in the interactive session.
173You can also change the prompts
174.I sys.ps1
175and
176.I sys.ps2
177in this file.
178.IP PYTHONDEBUG
179If this is set to a non-empty string it is equivalent to specifying
180the \fB\-d\fP option.
181.IP PYTHONINSPECT
182If this is set to a non-empty string it is equivalent to specifying
183the \fB\-i\fP option.
Guido van Rossum36a37341994-05-30 13:41:15 +0000184.IP PYTHONSUPPRESS
185If this is set to a non-empty string it is equivalent to specifying
186the \fB\-s\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000187.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000188If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000189the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000190.IP PYTHONVERBOSE
191If this is set to a non-empty string it is equivalent to specifying
192the \fB\-v\fP option.
193.SH SEE ALSO
194Python Tutorial
195.br
196Python Library Reference
197.br
198Python Reference Manual
199.br
200STDWIN under X11
201.SH BUGS AND CAVEATS
202The first time
203.I stdwin
204is imported, it initializes the STDWIN library.
205If this initialization fails, e.g. because the display connection
206fails, the interpreter aborts immediately.
207.SH AUTHOR
208.nf
209Guido van Rossum
210CWI (Centrum voor Wiskunde en Informatica)
211P.O. Box 4079
2121009 AB Amsterdam
213The Netherlands
214.PP
215E-mail: Guido.van.Rossum@cwi.nl
216.fi
217.SH MAILING LIST
218There is a mailing list devoted to Python programming, bugs and
219design.
220To subscribe, send mail containing your real name and e-mail address
221in Internet form to
222.I python-list-request@cwi.nl.
223.SH COPYRIGHT
Guido van Rossum227a0a11995-01-04 19:21:21 +0000224Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
225The Netherlands.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000226.IP " "
227All Rights Reserved
228.PP
Guido van Rossum227a0a11995-01-04 19:21:21 +0000229Permission to use, copy, modify, and distribute this software and its
230documentation for any purpose and without fee is hereby granted,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000231provided that the above copyright notice appear in all copies and that
Guido van Rossum227a0a11995-01-04 19:21:21 +0000232both that copyright notice and this permission notice appear in
Guido van Rossuma7925f11994-01-26 10:20:16 +0000233supporting documentation, and that the names of Stichting Mathematisch
234Centrum or CWI not be used in advertising or publicity pertaining to
235distribution of the software without specific, written prior permission.
236
237STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
238THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
239FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
240FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
241WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
242ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
243OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.