blob: 206f8bad11b3d00e59dbf05df4eb9f7fe904a2dc [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
50.TP
51.B \-d
52Turn on parser debugging output (for wizards only, depending on
53compilation options).
54.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
57command. This can be useful to inspect global variables or a stack
58trace when a script raises an exception.
59.TP
60.B \-i
61When executing a program from a file, this option enters interactive
62mode after the program has completed. It does not read the
63$PYTHONSTARTUP file.
64.TP
65.B \-k
66This hack, eh, feature is intended to help you to find expression
67statements that print a value. Although a feature of the language, it
68can sometimes be annoying that when a function is called which returns
69a value that is not
70.IR None ,
71the value is printed to standard output, and it is not always easy to
72find which statement is the cause of an unwanted `1', for instance.
73When this option is set, if an expression statement prints its value,
74the exception
75.I RuntimeError
76is raised. The resulting stack trace will help you to track down the
77culprit.
78.TP
79.B \-v
80Print a message each time a module is initialized, showing the place
81(filename or built-in module) from which it is loaded.
82.TP
83.BI "\-c " command
84Specify the command to execute (see next section).
85This terminates the option list (following options are passed as
86arguments to the command).
87.PP
88When the interpreter is configured to contain the
89.I stdwin
90built-in module for use with the X window system, additional command
91line options common to most X applications are recognized (by STDWIN),
92e.g.
93.B \-display
94.I displayname
95and
96.B \-geometry
97.I widthxheight+x+y.
98The complete set of options is described in the STDWIN documentation.
99.SH INTERPRETER INTERFACE
100The interpreter interface resembles that of the UNIX shell: when
101called with standard input connected to a tty device, it prompts for
102commands and executes them until an EOF is read; when called with a
103file name argument or with a file as standard input, it reads and
104executes a
105.I script
106from that file;
107when called with
108.B \-c
109.I command,
110it executes the Python statement(s) given as
111.I command.
112Here
113.I command
114may contain multiple statements separated by newlines.
115Leading whitespace is significant in Python statements!
116In non-interactive mode, the entire input is parsed befored it is
117executed.
118.PP
119If available, the script name and additional arguments thereafter are
120passed to the script in the Python variable
121.I sys.argv ,
122which is a list of strings (you must first
123.I import sys
124to be able to access it).
125If no script name is given,
126.I sys.argv
127is empty; if
128.B \-c
129is used,
130.I sys.argv[0]
131contains the string
132.I '-c'.
133Note that options interpreter by the Python interpreter or by STDWIN
134are not placed in
135.I sys.argv.
136.PP
137In interactive mode, the primary prompt is `>>>'; the second prompt
138(which appears when a command is not complete) is `...'.
139The prompts can be changed by assignment to
140.I sys.ps1
141or
142.I sys.ps2.
143The interpreter quits when it reads an EOF at a prompt.
144When an unhandled exception occurs, a stack trace is printed and
145control returns to the primary prompt; in non-interactive mode, the
146interpreter exits after printing the stack trace.
147The interrupt signal raises the
148.I Keyboard\%Interrupt
149exception; other UNIX signals are not caught (except that SIGPIPE is
150sometimes ignored, in favor of the
151.I IOError
152exception). Error messages are written to stderr.
153.SH FILES AND DIRECTORIES
154These are subject to difference depending on local installation
155conventions:
156.IP /usr/local/bin/python
157Recommended location of the interpreter.
158.IP /usr/local/lib/python
159Recommended location of the directory containing the standard modules.
160.SH ENVIRONMENT VARIABLES
161.IP PYTHONPATH
162Augments the default search path for module files.
163The format is the same as the shell's $PATH: one or more directory
164pathnames separated by colons.
165Non-existant directories are silently ignored.
166The default search path is installation dependent, but always begins
167with `.', (for example,
168.I .:/usr/local/lib/python ).
169The default search path is appended to $PYTHONPATH.
170The search path can be manipulated from within a Python program as the
171variable
172.I sys.path .
173.IP PYTHONSTARTUP
174If this is the name of a readable file, the Python commands in that
175file are executed before the first prompt is displayed in interactive
176mode.
177The file is executed in the same name space where interactive commands
178are executed so that objects defined or imported in it can be used
179without qualification in the interactive session.
180You can also change the prompts
181.I sys.ps1
182and
183.I sys.ps2
184in this file.
185.IP PYTHONDEBUG
186If this is set to a non-empty string it is equivalent to specifying
187the \fB\-d\fP option.
188.IP PYTHONINSPECT
189If this is set to a non-empty string it is equivalent to specifying
190the \fB\-i\fP option.
191.IP PYTHONKILLPRINT
192If this is set to a non-empty string it is equivalent to specifying
193the \fB\-k\fP option.
194.IP PYTHONVERBOSE
195If this is set to a non-empty string it is equivalent to specifying
196the \fB\-v\fP option.
197.SH SEE ALSO
198Python Tutorial
199.br
200Python Library Reference
201.br
202Python Reference Manual
203.br
204STDWIN under X11
205.SH BUGS AND CAVEATS
206The first time
207.I stdwin
208is imported, it initializes the STDWIN library.
209If this initialization fails, e.g. because the display connection
210fails, the interpreter aborts immediately.
211.SH AUTHOR
212.nf
213Guido van Rossum
214CWI (Centrum voor Wiskunde en Informatica)
215P.O. Box 4079
2161009 AB Amsterdam
217The Netherlands
218.PP
219E-mail: Guido.van.Rossum@cwi.nl
220.fi
221.SH MAILING LIST
222There is a mailing list devoted to Python programming, bugs and
223design.
224To subscribe, send mail containing your real name and e-mail address
225in Internet form to
226.I python-list-request@cwi.nl.
227.SH COPYRIGHT
228Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
229Amsterdam, The Netherlands.
230.IP " "
231All Rights Reserved
232.PP
233Permission to use, copy, modify, and distribute this software and its
234documentation for any purpose and without fee is hereby granted,
235provided that the above copyright notice appear in all copies and that
236both that copyright notice and this permission notice appear in
237supporting documentation, and that the names of Stichting Mathematisch
238Centrum or CWI not be used in advertising or publicity pertaining to
239distribution of the software without specific, written prior permission.
240
241STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
242THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
243FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
244FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
245WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
246ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
247OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.