blob: 2697bc7822c05254c216e5171ddee76688e02350 [file] [log] [blame]
Guido van Rossumf4a090d2000-09-01 20:36:34 +00001.TH PYTHON "1" "5 September, 2000"
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]
Guido van Rossum07c44c71998-04-10 19:46:00 +000027[
Guido van Rossumf4a090d2000-09-01 20:36:34 +000028.B \-x
Guido van Rossum4cf4de51997-09-08 04:06:15 +000029]
Barry Warsaw64569372000-09-15 18:39:09 +000030[
31.B \-h
32]
33[
34.B \-V
35]
Guido van Rossum1378c322000-12-19 03:21:54 +000036[
37.B \-W
38.I argument
39]
Guido van Rossum4cf4de51997-09-08 04:06:15 +000040.br
41 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000042.B \-c
43.I command
44|
45.I script
46|
47\-
48]
49[
50.I arguments
51]
52.SH DESCRIPTION
53Python is an interpreted, interactive, object-oriented programming
54language that combines remarkable power with very clear syntax.
55For an introduction to programming in Python you are referred to the
56Python Tutorial.
57The Python Library Reference documents built-in and standard types,
58constants, functions and modules.
59Finally, the Python Reference Manual describes the syntax and
60semantics of the core language in (perhaps too) much detail.
Guido van Rossumf4a090d2000-09-01 20:36:34 +000061(These documents may be located via the
62.B "INTERNET RESOURCES"
Fred Drake4c9be9d1999-08-20 13:10:20 +000063below; they may be installed on your system as well.)
Guido van Rossuma7925f11994-01-26 10:20:16 +000064.PP
65Python's basic power can be extended with your own modules written in
66C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000067On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000068Python is also adaptable as an extension language for existing
69applications.
70See the internal documentation for hints.
Andrew M. Kuchling88717f42001-04-05 14:50:40 +000071.PP
72Documentation for installed Python modules and packages can be
73viewed by running the
74.B pydoc
75program.
Guido van Rossuma7925f11994-01-26 10:20:16 +000076.SH COMMAND LINE OPTIONS
77.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000078.B \-d
79Turn on parser debugging output (for wizards only, depending on
80compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000081.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000082.B \-i
83When a script is passed as first argument or the \fB\-c\fP option is
84used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000085command. It does not read the $PYTHONSTARTUP file. This can be
86useful to inspect global variables or a stack trace when a script
87raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000088.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000089.B \-O
90Turn on basic optimizations. This changes the filename extension for
91compiled (bytecode) files from
92.I .pyc
Fred Drake4c9be9d1999-08-20 13:10:20 +000093to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
Guido van Rossum4cf4de51997-09-08 04:06:15 +000094.TP
95.B \-S
96Disable the import of the module
97.I site
98and the site-dependent manipulations of
99.I sys.path
100that it entails.
101.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +0000102.B \-t
103Issue a warning when a source file mixes tabs and spaces for
104indentation in a way that makes it depend on the worth of a tab
105expressed in spaces. Issue an error when the option is given twice.
106.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +0000107.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000108Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000109.TP
110.B \-v
111Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +0000112(filename or built-in module) from which it is loaded. When given
113twice, print a message for each file that is checked for when
114searching for a module. Also provides information on module cleanup
115at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000116.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000117.B \-x
118Skip the first line of the source. This is intended for a DOS
119specific hack only. Warning: the line numbers in error messages will
120be off by one!
121.TP
Barry Warsaw64569372000-09-15 18:39:09 +0000122.B \-h
123Prints the usage for the interpreter executable and exits.
124.TP
125.B \-V
126Prints the Python version number of the executable and exits.
127.TP
Guido van Rossum1378c322000-12-19 03:21:54 +0000128.BI "\-W " argument
129Warning control. Python sometimes prints warning message to
130.IR sys.stderr .
131A typical warning message has the following form:
132.IB file ":" line ": " category ": " message.
133By default, each warning is printed once for each source line where it
134occurs. This option controls how often warnings are printed.
135Multiple
136.B \-W
137options may be given; when a warning matches more than one
138option, the action for the last matching option is performed.
139Invalid
140.B \-W
141options are ignored (a warning message is printed about invalid
142options when the first warning is issued). Warnings can also be
143controlled from within a Python program using the
144.I warnings
145module.
146
147The simplest form of
148.I argument
149is one of the following
150.I action
151strings (or a unique abbreviation):
152.B ignore
153to ignore all warnings;
154.B default
155to explicitly request the default behavior (printing each warning once
156per source line);
157.B all
158to print a warning each time it occurs (this may generate many
159messages if a warning is triggered repeatedly for the same source
160line, e.g. inside a loop);
161.B module
162to print each warning only only the first time it occurs in each
163module;
164.B once
165to print each warning only the first time it occurs in the program; or
166.B error
167to raise an exception instead of printing a warning message.
168
169The full form of
170.I argument
171is
172.IB action : message : category : module : line.
173Here,
174.I action
175is as explained above but only applies to messages that match the
176remaining fields. Empty fields match all values; trailing empty
177fields may be omitted. The
178.I message
179field matches the start of the warning message printed; this match is
180case-insensitive. The
181.I category
182field matches the warning category. This must be a class name; the
183match test whether the actual warning category of the message is a
184subclass of the specified warning category. The full class name must
185be given. The
186.I module
187field matches the (fully-qualified) module name; this match is
188case-sensitive. The
189.I line
190field matches the line number, where zero matches all line numbers and
191is thus equivalent to an omitted line number.
192.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000193.BI "\-c " command
194Specify the command to execute (see next section).
195This terminates the option list (following options are passed as
196arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000197.SH INTERPRETER INTERFACE
198The interpreter interface resembles that of the UNIX shell: when
199called with standard input connected to a tty device, it prompts for
200commands and executes them until an EOF is read; when called with a
201file name argument or with a file as standard input, it reads and
202executes a
203.I script
204from that file;
205when called with
206.B \-c
207.I command,
208it executes the Python statement(s) given as
209.I command.
210Here
211.I command
212may contain multiple statements separated by newlines.
213Leading whitespace is significant in Python statements!
214In non-interactive mode, the entire input is parsed befored it is
215executed.
216.PP
217If available, the script name and additional arguments thereafter are
218passed to the script in the Python variable
219.I sys.argv ,
220which is a list of strings (you must first
221.I import sys
222to be able to access it).
223If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000224.I sys.argv[0]
225is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000226.B \-c
227is used,
228.I sys.argv[0]
229contains the string
230.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000231Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000232are not placed in
233.I sys.argv.
234.PP
235In interactive mode, the primary prompt is `>>>'; the second prompt
236(which appears when a command is not complete) is `...'.
237The prompts can be changed by assignment to
238.I sys.ps1
239or
240.I sys.ps2.
241The interpreter quits when it reads an EOF at a prompt.
242When an unhandled exception occurs, a stack trace is printed and
243control returns to the primary prompt; in non-interactive mode, the
244interpreter exits after printing the stack trace.
245The interrupt signal raises the
246.I Keyboard\%Interrupt
247exception; other UNIX signals are not caught (except that SIGPIPE is
248sometimes ignored, in favor of the
249.I IOError
250exception). Error messages are written to stderr.
251.SH FILES AND DIRECTORIES
252These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000253conventions; ${prefix} and ${exec_prefix} are installation-dependent
254and should be interpreted as for GNU software; they may be the same.
255The default for both is \fI/usr/local\fP.
256.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000257Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000258.PP
259.I ${prefix}/lib/python<version>
260.br
261.I ${exec_prefix}/lib/python<version>
262.RS
263Recommended locations of the directories containing the standard
264modules.
265.RE
266.PP
267.I ${prefix}/include/python<version>
268.br
269.I ${exec_prefix}/include/python<version>
270.RS
271Recommended locations of the directories containing the include files
272needed for developing Python extensions and embedding the
273interpreter.
274.RE
275.IP \fI~/.pythonrc.py\fP
276User-specific initialization file loaded by the \fIuser\fP module;
277not used by default or by most applications.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000278.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000279.IP PYTHONHOME
280Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000281libraries are searched in ${prefix}/lib/python<version> and
282${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000283are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000284\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
285replaces both ${prefix} and ${exec_prefix}. To specify different values
286for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000287.IP PYTHONPATH
288Augments the default search path for module files.
289The format is the same as the shell's $PATH: one or more directory
290pathnames separated by colons.
291Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000292The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000293begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000294The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000295If a script argument is given, the directory containing the script is
296inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000297The search path can be manipulated from within a Python program as the
298variable
299.I sys.path .
300.IP PYTHONSTARTUP
301If this is the name of a readable file, the Python commands in that
302file are executed before the first prompt is displayed in interactive
303mode.
304The file is executed in the same name space where interactive commands
305are executed so that objects defined or imported in it can be used
306without qualification in the interactive session.
307You can also change the prompts
308.I sys.ps1
309and
310.I sys.ps2
311in this file.
312.IP PYTHONDEBUG
313If this is set to a non-empty string it is equivalent to specifying
314the \fB\-d\fP option.
315.IP PYTHONINSPECT
316If this is set to a non-empty string it is equivalent to specifying
317the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000318.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000319If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000320the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000321.IP PYTHONVERBOSE
322If this is set to a non-empty string it is equivalent to specifying
323the \fB\-v\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000324.SH AUTHOR
325.nf
326Guido van Rossum
Guido van Rossuma7925f11994-01-26 10:20:16 +0000327.PP
Guido van Rossum1378c322000-12-19 03:21:54 +0000328E-mail: guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000329.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000330.PP
331And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000332.SH INTERNET RESOURCES
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000333Main website: http://www.python.org
Guido van Rossum74faed21996-07-30 19:27:05 +0000334.br
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000335Community website: http://starship.python.net
336.br
337Developer resources:
338.br
339 http://sourceforge.net/project/?group_id=5470
340.br
341FTP: ftp://ftp.python.org/pub/python
342.br
343Module repository: http://www.vex.net/parnassus/
Guido van Rossum74faed21996-07-30 19:27:05 +0000344.br
Fred Drake4c9be9d1999-08-20 13:10:20 +0000345Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000346.SH LICENSING
347Python is distributed under an Open Source license. See the file
348"LICENSE" in the Python source distribution for information on terms &
349conditions for accessing and otherwise using Python and for a
350DISCLAIMER OF ALL WARRANTIES.