blob: 475c6e1875fe26d8cf87f33d6552d9dae7cfccde [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 Rossumef5bca31994-05-03 14:15:32 +000013.B \-u
Guido van Rossuma7925f11994-01-26 10:20:16 +000014]
15[
16.B \-v
17]
18[
19.B \-c
20.I command
21|
22.I script
23|
24\-
25]
26[
27.I arguments
28]
29.SH DESCRIPTION
30Python is an interpreted, interactive, object-oriented programming
31language that combines remarkable power with very clear syntax.
32For an introduction to programming in Python you are referred to the
33Python Tutorial.
34The Python Library Reference documents built-in and standard types,
35constants, functions and modules.
36Finally, the Python Reference Manual describes the syntax and
37semantics of the core language in (perhaps too) much detail.
38.PP
39Python's basic power can be extended with your own modules written in
40C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000041On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000042Python is also adaptable as an extension language for existing
43applications.
44See the internal documentation for hints.
45.SH COMMAND LINE OPTIONS
46.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000047.B \-d
48Turn on parser debugging output (for wizards only, depending on
49compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000050.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000051.B \-i
52When a script is passed as first argument or the \fB\-c\fP option is
53used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000054command. It does not read the $PYTHONSTARTUP file. This can be
55useful to inspect global variables or a stack trace when a script
56raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000057.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000058.B \-u
59Force stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000060.TP
61.B \-v
62Print a message each time a module is initialized, showing the place
63(filename or built-in module) from which it is loaded.
64.TP
65.BI "\-c " command
66Specify the command to execute (see next section).
67This terminates the option list (following options are passed as
68arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +000069.SH INTERPRETER INTERFACE
70The interpreter interface resembles that of the UNIX shell: when
71called with standard input connected to a tty device, it prompts for
72commands and executes them until an EOF is read; when called with a
73file name argument or with a file as standard input, it reads and
74executes a
75.I script
76from that file;
77when called with
78.B \-c
79.I command,
80it executes the Python statement(s) given as
81.I command.
82Here
83.I command
84may contain multiple statements separated by newlines.
85Leading whitespace is significant in Python statements!
86In non-interactive mode, the entire input is parsed befored it is
87executed.
88.PP
89If available, the script name and additional arguments thereafter are
90passed to the script in the Python variable
91.I sys.argv ,
92which is a list of strings (you must first
93.I import sys
94to be able to access it).
95If no script name is given,
96.I sys.argv
97is empty; if
98.B \-c
99is used,
100.I sys.argv[0]
101contains the string
102.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000103Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000104are not placed in
105.I sys.argv.
106.PP
107In interactive mode, the primary prompt is `>>>'; the second prompt
108(which appears when a command is not complete) is `...'.
109The prompts can be changed by assignment to
110.I sys.ps1
111or
112.I sys.ps2.
113The interpreter quits when it reads an EOF at a prompt.
114When an unhandled exception occurs, a stack trace is printed and
115control returns to the primary prompt; in non-interactive mode, the
116interpreter exits after printing the stack trace.
117The interrupt signal raises the
118.I Keyboard\%Interrupt
119exception; other UNIX signals are not caught (except that SIGPIPE is
120sometimes ignored, in favor of the
121.I IOError
122exception). Error messages are written to stderr.
123.SH FILES AND DIRECTORIES
124These are subject to difference depending on local installation
125conventions:
126.IP /usr/local/bin/python
127Recommended location of the interpreter.
Guido van Rossum74faed21996-07-30 19:27:05 +0000128.IP /usr/local/lib/python1.4
Guido van Rossuma7925f11994-01-26 10:20:16 +0000129Recommended location of the directory containing the standard modules.
130.SH ENVIRONMENT VARIABLES
131.IP PYTHONPATH
132Augments the default search path for module files.
133The format is the same as the shell's $PATH: one or more directory
134pathnames separated by colons.
135Non-existant directories are silently ignored.
136The default search path is installation dependent, but always begins
137with `.', (for example,
138.I .:/usr/local/lib/python ).
139The default search path is appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000140If a script argument is given, the directory containing the script is
141inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000142The search path can be manipulated from within a Python program as the
143variable
144.I sys.path .
145.IP PYTHONSTARTUP
146If this is the name of a readable file, the Python commands in that
147file are executed before the first prompt is displayed in interactive
148mode.
149The file is executed in the same name space where interactive commands
150are executed so that objects defined or imported in it can be used
151without qualification in the interactive session.
152You can also change the prompts
153.I sys.ps1
154and
155.I sys.ps2
156in this file.
157.IP PYTHONDEBUG
158If this is set to a non-empty string it is equivalent to specifying
159the \fB\-d\fP option.
160.IP PYTHONINSPECT
161If this is set to a non-empty string it is equivalent to specifying
162the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000163.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000164If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000165the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000166.IP PYTHONVERBOSE
167If this is set to a non-empty string it is equivalent to specifying
168the \fB\-v\fP option.
169.SH SEE ALSO
170Python Tutorial
171.br
172Python Library Reference
173.br
174Python Reference Manual
Guido van Rossuma7925f11994-01-26 10:20:16 +0000175.SH AUTHOR
176.nf
177Guido van Rossum
Guido van Rossum74faed21996-07-30 19:27:05 +0000178CNRI
1791895 Preston White Drive
180Reston, VA 20191
181USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000182.PP
Guido van Rossum74faed21996-07-30 19:27:05 +0000183E-mail: guido@cnri.reston.va.us, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000184.fi
Guido van Rossum74faed21996-07-30 19:27:05 +0000185.SH INTERNET RESOURCES
186Web site: http://www.python.org
187.br
188FTP site: ftp://ftp.python.org
189.br
190Newsgroup: comp.lang.python
Guido van Rossuma7925f11994-01-26 10:20:16 +0000191.SH COPYRIGHT
Guido van Rossum227a0a11995-01-04 19:21:21 +0000192Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
193The Netherlands.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000194.IP " "
195All Rights Reserved
196.PP
Guido van Rossum227a0a11995-01-04 19:21:21 +0000197Permission to use, copy, modify, and distribute this software and its
198documentation for any purpose and without fee is hereby granted,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000199provided that the above copyright notice appear in all copies and that
Guido van Rossum227a0a11995-01-04 19:21:21 +0000200both that copyright notice and this permission notice appear in
Guido van Rossuma7925f11994-01-26 10:20:16 +0000201supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +0000202Centrum or CWI or Corporation for National Research Initiatives or
203CNRI not be used in advertising or publicity pertaining to
204distribution of the software without specific, written prior
205permission.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000206
Guido van Rossumd266eb41996-10-25 14:44:06 +0000207While CWI is the initial source for this software, a modified version
208is made available by the Corporation for National Research Initiatives
209(CNRI) at the Internet address ftp://ftp.python.org.
210
211STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
212REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
213MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
214CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
215DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
216PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
217TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
218PERFORMANCE OF THIS SOFTWARE.