blob: a67bcca57904f193e05b4500098dfe43fed5dee4 [file] [log] [blame]
Guido van Rossum29d465b1998-04-10 19:36:09 +00001.TH PYTHON "10 April, 1998"
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 Rossum4cf4de51997-09-08 04:06:15 +000013.B \-O
14]
15[
16.B \-S
17]
18[
Guido van Rossum29d465b1998-04-10 19:36:09 +000019.B \-t
20]
21[
Guido van Rossumef5bca31994-05-03 14:15:32 +000022.B \-u
Guido van Rossuma7925f11994-01-26 10:20:16 +000023]
24[
25.B \-v
26]
27[
Guido van Rossum07c44c71998-04-10 19:46:00 +000028.B \-x
29]
30[
Guido van Rossum4cf4de51997-09-08 04:06:15 +000031.B \-X
32]
33.br
34 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000035.B \-c
36.I command
37|
38.I script
39|
40\-
41]
42[
43.I arguments
44]
45.SH DESCRIPTION
46Python is an interpreted, interactive, object-oriented programming
47language that combines remarkable power with very clear syntax.
48For an introduction to programming in Python you are referred to the
49Python Tutorial.
50The Python Library Reference documents built-in and standard types,
51constants, functions and modules.
52Finally, the Python Reference Manual describes the syntax and
53semantics of the core language in (perhaps too) much detail.
54.PP
55Python's basic power can be extended with your own modules written in
56C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000057On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000058Python is also adaptable as an extension language for existing
59applications.
60See the internal documentation for hints.
61.SH COMMAND LINE OPTIONS
62.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000063.B \-d
64Turn on parser debugging output (for wizards only, depending on
65compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000066.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000067.B \-i
68When a script is passed as first argument or the \fB\-c\fP option is
69used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000070command. It does not read the $PYTHONSTARTUP file. This can be
71useful to inspect global variables or a stack trace when a script
72raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000073.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000074.B \-O
75Turn on basic optimizations. This changes the filename extension for
76compiled (bytecode) files from
77.I .pyc
78to
79.I pyo.
80.TP
81.B \-S
82Disable the import of the module
83.I site
84and the site-dependent manipulations of
85.I sys.path
86that it entails.
87.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +000088.B \-t
89Issue a warning when a source file mixes tabs and spaces for
90indentation in a way that makes it depend on the worth of a tab
91expressed in spaces. Issue an error when the option is given twice.
92.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000093.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +000094Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000095.TP
96.B \-v
97Print a message each time a module is initialized, showing the place
98(filename or built-in module) from which it is loaded.
99.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000100.B \-x
101Skip the first line of the source. This is intended for a DOS
102specific hack only. Warning: the line numbers in error messages will
103be off by one!
104.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000105.B \-X
106Make the standard exceptions strings instead of classes.
107Use for backward compatibility with old code only.
108.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000109.BI "\-c " command
110Specify the command to execute (see next section).
111This terminates the option list (following options are passed as
112arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000113.SH INTERPRETER INTERFACE
114The interpreter interface resembles that of the UNIX shell: when
115called with standard input connected to a tty device, it prompts for
116commands and executes them until an EOF is read; when called with a
117file name argument or with a file as standard input, it reads and
118executes a
119.I script
120from that file;
121when called with
122.B \-c
123.I command,
124it executes the Python statement(s) given as
125.I command.
126Here
127.I command
128may contain multiple statements separated by newlines.
129Leading whitespace is significant in Python statements!
130In non-interactive mode, the entire input is parsed befored it is
131executed.
132.PP
133If available, the script name and additional arguments thereafter are
134passed to the script in the Python variable
135.I sys.argv ,
136which is a list of strings (you must first
137.I import sys
138to be able to access it).
139If no script name is given,
140.I sys.argv
141is empty; if
142.B \-c
143is used,
144.I sys.argv[0]
145contains the string
146.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000147Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000148are not placed in
149.I sys.argv.
150.PP
151In interactive mode, the primary prompt is `>>>'; the second prompt
152(which appears when a command is not complete) is `...'.
153The prompts can be changed by assignment to
154.I sys.ps1
155or
156.I sys.ps2.
157The interpreter quits when it reads an EOF at a prompt.
158When an unhandled exception occurs, a stack trace is printed and
159control returns to the primary prompt; in non-interactive mode, the
160interpreter exits after printing the stack trace.
161The interrupt signal raises the
162.I Keyboard\%Interrupt
163exception; other UNIX signals are not caught (except that SIGPIPE is
164sometimes ignored, in favor of the
165.I IOError
166exception). Error messages are written to stderr.
167.SH FILES AND DIRECTORIES
168These are subject to difference depending on local installation
169conventions:
170.IP /usr/local/bin/python
171Recommended location of the interpreter.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000172.IP /usr/local/lib/python<version>
Guido van Rossuma7925f11994-01-26 10:20:16 +0000173Recommended location of the directory containing the standard modules.
174.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000175.IP PYTHONHOME
176Change the location of the standard Python libraries. By default, the
177libraries are searched in <prefix>/lib/python<version> and
178<exec_prefix>/lib/python<version>, where <prefix> and <exec_prefix>
179are installation-dependent directories, both defaulting to
180/usr/local. When $PYTHONHOME is set to a single directory, its value
181replaces both <prefix> and <exec_prefix>. To specify different values
182for these, set $PYTHONHOME to <prefix>:<exec_prefix>.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000183.IP PYTHONPATH
184Augments the default search path for module files.
185The format is the same as the shell's $PATH: one or more directory
186pathnames separated by colons.
187Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000188The default search path is installation dependent, but generally
189begins with <prefix>/lib/python<version> (see PYTHONHOME below).
190The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000191If a script argument is given, the directory containing the script is
192inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000193The search path can be manipulated from within a Python program as the
194variable
195.I sys.path .
196.IP PYTHONSTARTUP
197If this is the name of a readable file, the Python commands in that
198file are executed before the first prompt is displayed in interactive
199mode.
200The file is executed in the same name space where interactive commands
201are executed so that objects defined or imported in it can be used
202without qualification in the interactive session.
203You can also change the prompts
204.I sys.ps1
205and
206.I sys.ps2
207in this file.
208.IP PYTHONDEBUG
209If this is set to a non-empty string it is equivalent to specifying
210the \fB\-d\fP option.
211.IP PYTHONINSPECT
212If this is set to a non-empty string it is equivalent to specifying
213the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000214.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000215If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000216the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000217.IP PYTHONVERBOSE
218If this is set to a non-empty string it is equivalent to specifying
219the \fB\-v\fP option.
220.SH SEE ALSO
221Python Tutorial
222.br
223Python Library Reference
224.br
225Python Reference Manual
Guido van Rossuma7925f11994-01-26 10:20:16 +0000226.SH AUTHOR
227.nf
228Guido van Rossum
Guido van Rossum74faed21996-07-30 19:27:05 +0000229CNRI
2301895 Preston White Drive
231Reston, VA 20191
232USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000233.PP
Guido van Rossum74faed21996-07-30 19:27:05 +0000234E-mail: guido@cnri.reston.va.us, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000235.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000236.PP
237And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000238.SH INTERNET RESOURCES
239Web site: http://www.python.org
240.br
241FTP site: ftp://ftp.python.org
242.br
243Newsgroup: comp.lang.python
Guido van Rossuma7925f11994-01-26 10:20:16 +0000244.SH COPYRIGHT
Guido van Rossum227a0a11995-01-04 19:21:21 +0000245Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
246The Netherlands.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000247.IP " "
248All Rights Reserved
249.PP
Guido van Rossum227a0a11995-01-04 19:21:21 +0000250Permission to use, copy, modify, and distribute this software and its
251documentation for any purpose and without fee is hereby granted,
Guido van Rossuma7925f11994-01-26 10:20:16 +0000252provided that the above copyright notice appear in all copies and that
Guido van Rossum227a0a11995-01-04 19:21:21 +0000253both that copyright notice and this permission notice appear in
Guido van Rossuma7925f11994-01-26 10:20:16 +0000254supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +0000255Centrum or CWI or Corporation for National Research Initiatives or
256CNRI not be used in advertising or publicity pertaining to
257distribution of the software without specific, written prior
258permission.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000259
Guido van Rossumd266eb41996-10-25 14:44:06 +0000260While CWI is the initial source for this software, a modified version
261is made available by the Corporation for National Research Initiatives
262(CNRI) at the Internet address ftp://ftp.python.org.
263
264STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
265REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
266MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
267CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
268DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
269PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
270TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
271PERFORMANCE OF THIS SOFTWARE.