blob: a7bfbc4b6454ae491849e1bbf2ba56b929d66091 [file] [log] [blame]
Guido van Rossum74faed21996-07-30 19:27:05 +00001.TH PYTHON "30 July 1996"
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 Rossum36a37341994-05-30 13:41:15 +000013.B \-s
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++.
Guido van Rossum74faed21996-07-30 19:27:05 +000044On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000045Python 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 Rossum36a37341994-05-30 13:41:15 +000061.B \-s
62Suppresses the automatic printing of expressions entered in
63interactive mode (useful when input is actually generated e.g. by
64Emacs).
65.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000066.B \-u
67Force stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000068.TP
69.B \-v
70Print a message each time a module is initialized, showing the place
71(filename or built-in module) from which it is loaded.
72.TP
73.BI "\-c " command
74Specify the command to execute (see next section).
75This terminates the option list (following options are passed as
76arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +000077.SH INTERPRETER INTERFACE
78The interpreter interface resembles that of the UNIX shell: when
79called with standard input connected to a tty device, it prompts for
80commands and executes them until an EOF is read; when called with a
81file name argument or with a file as standard input, it reads and
82executes a
83.I script
84from that file;
85when called with
86.B \-c
87.I command,
88it executes the Python statement(s) given as
89.I command.
90Here
91.I command
92may contain multiple statements separated by newlines.
93Leading whitespace is significant in Python statements!
94In non-interactive mode, the entire input is parsed befored it is
95executed.
96.PP
97If available, the script name and additional arguments thereafter are
98passed to the script in the Python variable
99.I sys.argv ,
100which is a list of strings (you must first
101.I import sys
102to be able to access it).
103If no script name is given,
104.I sys.argv
105is empty; if
106.B \-c
107is used,
108.I sys.argv[0]
109contains the string
110.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000111Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000112are not placed in
113.I sys.argv.
114.PP
115In interactive mode, the primary prompt is `>>>'; the second prompt
116(which appears when a command is not complete) is `...'.
117The prompts can be changed by assignment to
118.I sys.ps1
119or
120.I sys.ps2.
121The interpreter quits when it reads an EOF at a prompt.
122When an unhandled exception occurs, a stack trace is printed and
123control returns to the primary prompt; in non-interactive mode, the
124interpreter exits after printing the stack trace.
125The interrupt signal raises the
126.I Keyboard\%Interrupt
127exception; other UNIX signals are not caught (except that SIGPIPE is
128sometimes ignored, in favor of the
129.I IOError
130exception). Error messages are written to stderr.
131.SH FILES AND DIRECTORIES
132These are subject to difference depending on local installation
133conventions:
134.IP /usr/local/bin/python
135Recommended location of the interpreter.
Guido van Rossum74faed21996-07-30 19:27:05 +0000136.IP /usr/local/lib/python1.4
Guido van Rossuma7925f11994-01-26 10:20:16 +0000137Recommended location of the directory containing the standard modules.
138.SH ENVIRONMENT VARIABLES
139.IP PYTHONPATH
140Augments the default search path for module files.
141The format is the same as the shell's $PATH: one or more directory
142pathnames separated by colons.
143Non-existant directories are silently ignored.
144The default search path is installation dependent, but always begins
145with `.', (for example,
146.I .:/usr/local/lib/python ).
147The default search path is appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000148If a script argument is given, the directory containing the script is
149inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000150The search path can be manipulated from within a Python program as the
151variable
152.I sys.path .
153.IP PYTHONSTARTUP
154If this is the name of a readable file, the Python commands in that
155file are executed before the first prompt is displayed in interactive
156mode.
157The file is executed in the same name space where interactive commands
158are executed so that objects defined or imported in it can be used
159without qualification in the interactive session.
160You can also change the prompts
161.I sys.ps1
162and
163.I sys.ps2
164in this file.
165.IP PYTHONDEBUG
166If this is set to a non-empty string it is equivalent to specifying
167the \fB\-d\fP option.
168.IP PYTHONINSPECT
169If this is set to a non-empty string it is equivalent to specifying
170the \fB\-i\fP option.
Guido van Rossum36a37341994-05-30 13:41:15 +0000171.IP PYTHONSUPPRESS
172If this is set to a non-empty string it is equivalent to specifying
173the \fB\-s\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000174.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000175If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000176the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000177.IP PYTHONVERBOSE
178If this is set to a non-empty string it is equivalent to specifying
179the \fB\-v\fP option.
180.SH SEE ALSO
181Python Tutorial
182.br
183Python Library Reference
184.br
185Python Reference Manual
Guido van Rossuma7925f11994-01-26 10:20:16 +0000186.SH AUTHOR
187.nf
188Guido van Rossum
Guido van Rossum74faed21996-07-30 19:27:05 +0000189CNRI
1901895 Preston White Drive
191Reston, VA 20191
192USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000193.PP
Guido van Rossum74faed21996-07-30 19:27:05 +0000194E-mail: guido@cnri.reston.va.us, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000195.fi
Guido van Rossum74faed21996-07-30 19:27:05 +0000196.SH INTERNET RESOURCES
197Web site: http://www.python.org
198.br
199FTP site: ftp://ftp.python.org
200.br
201Newsgroup: comp.lang.python
Guido van Rossuma7925f11994-01-26 10:20:16 +0000202.SH COPYRIGHT
Guido van Rossum227a0a11995-01-04 19:21:21 +0000203Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
204The Netherlands.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000205.IP " "
206All Rights Reserved
207.PP
Guido van Rossum227a0a11995-01-04 19:21:21 +0000208Permission to use, copy, modify, and distribute this software and its
209documentation for any purpose and without fee is hereby granted,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000210provided that the above copyright notice appear in all copies and that
Guido van Rossum227a0a11995-01-04 19:21:21 +0000211both that copyright notice and this permission notice appear in
Guido van Rossuma7925f11994-01-26 10:20:16 +0000212supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +0000213Centrum or CWI or Corporation for National Research Initiatives or
214CNRI not be used in advertising or publicity pertaining to
215distribution of the software without specific, written prior
216permission.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000217
Guido van Rossumd266eb41996-10-25 14:44:06 +0000218While CWI is the initial source for this software, a modified version
219is made available by the Corporation for National Research Initiatives
220(CNRI) at the Internet address ftp://ftp.python.org.
221
222STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
223REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
224MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
225CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
226DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
227PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
228TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
229PERFORMANCE OF THIS SOFTWARE.