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