blob: 052240e96d42256d325c6ecc7f4eeacb7cbd40f2 [file] [log] [blame]
Guido van Rossuma7925f11994-01-26 10:20:16 +00001.TH PYTHON "3 January 1994"
2.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[
16.B \-k
17]
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
61.B \-k
62This hack, eh, feature is intended to help you to find expression
63statements that print a value. Although a feature of the language, it
64can sometimes be annoying that when a function is called which returns
65a value that is not
66.IR None ,
67the value is printed to standard output, and it is not always easy to
68find which statement is the cause of an unwanted `1', for instance.
69When this option is set, if an expression statement prints its value,
70the exception
71.I RuntimeError
72is raised. The resulting stack trace will help you to track down the
73culprit.
74.TP
75.B \-v
76Print a message each time a module is initialized, showing the place
77(filename or built-in module) from which it is loaded.
78.TP
79.BI "\-c " command
80Specify the command to execute (see next section).
81This terminates the option list (following options are passed as
82arguments to the command).
83.PP
84When the interpreter is configured to contain the
85.I stdwin
86built-in module for use with the X window system, additional command
87line options common to most X applications are recognized (by STDWIN),
88e.g.
89.B \-display
90.I displayname
91and
92.B \-geometry
93.I widthxheight+x+y.
94The complete set of options is described in the STDWIN documentation.
95.SH INTERPRETER INTERFACE
96The interpreter interface resembles that of the UNIX shell: when
97called with standard input connected to a tty device, it prompts for
98commands and executes them until an EOF is read; when called with a
99file name argument or with a file as standard input, it reads and
100executes a
101.I script
102from that file;
103when called with
104.B \-c
105.I command,
106it executes the Python statement(s) given as
107.I command.
108Here
109.I command
110may contain multiple statements separated by newlines.
111Leading whitespace is significant in Python statements!
112In non-interactive mode, the entire input is parsed befored it is
113executed.
114.PP
115If available, the script name and additional arguments thereafter are
116passed to the script in the Python variable
117.I sys.argv ,
118which is a list of strings (you must first
119.I import sys
120to be able to access it).
121If no script name is given,
122.I sys.argv
123is empty; if
124.B \-c
125is used,
126.I sys.argv[0]
127contains the string
128.I '-c'.
129Note that options interpreter by the Python interpreter or by STDWIN
130are not placed in
131.I sys.argv.
132.PP
133In interactive mode, the primary prompt is `>>>'; the second prompt
134(which appears when a command is not complete) is `...'.
135The prompts can be changed by assignment to
136.I sys.ps1
137or
138.I sys.ps2.
139The interpreter quits when it reads an EOF at a prompt.
140When an unhandled exception occurs, a stack trace is printed and
141control returns to the primary prompt; in non-interactive mode, the
142interpreter exits after printing the stack trace.
143The interrupt signal raises the
144.I Keyboard\%Interrupt
145exception; other UNIX signals are not caught (except that SIGPIPE is
146sometimes ignored, in favor of the
147.I IOError
148exception). Error messages are written to stderr.
149.SH FILES AND DIRECTORIES
150These are subject to difference depending on local installation
151conventions:
152.IP /usr/local/bin/python
153Recommended location of the interpreter.
154.IP /usr/local/lib/python
155Recommended location of the directory containing the standard modules.
156.SH ENVIRONMENT VARIABLES
157.IP PYTHONPATH
158Augments the default search path for module files.
159The format is the same as the shell's $PATH: one or more directory
160pathnames separated by colons.
161Non-existant directories are silently ignored.
162The default search path is installation dependent, but always begins
163with `.', (for example,
164.I .:/usr/local/lib/python ).
165The default search path is appended to $PYTHONPATH.
166The search path can be manipulated from within a Python program as the
167variable
168.I sys.path .
169.IP PYTHONSTARTUP
170If this is the name of a readable file, the Python commands in that
171file are executed before the first prompt is displayed in interactive
172mode.
173The file is executed in the same name space where interactive commands
174are executed so that objects defined or imported in it can be used
175without qualification in the interactive session.
176You can also change the prompts
177.I sys.ps1
178and
179.I sys.ps2
180in this file.
181.IP PYTHONDEBUG
182If this is set to a non-empty string it is equivalent to specifying
183the \fB\-d\fP option.
184.IP PYTHONINSPECT
185If this is set to a non-empty string it is equivalent to specifying
186the \fB\-i\fP option.
187.IP PYTHONKILLPRINT
188If this is set to a non-empty string it is equivalent to specifying
189the \fB\-k\fP option.
190.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
224Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
225Amsterdam, The Netherlands.
226.IP " "
227All Rights Reserved
228.PP
229Permission to use, copy, modify, and distribute this software and its
230documentation for any purpose and without fee is hereby granted,
231provided that the above copyright notice appear in all copies and that
232both that copyright notice and this permission notice appear in
233supporting 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.