blob: 92f267b4c95d431806774b47a2b48f26fc45d0b6 [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[
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +000019.B \-E
20]
21[
Guido van Rossum29d465b1998-04-10 19:36:09 +000022.B \-t
23]
24[
Guido van Rossumef5bca31994-05-03 14:15:32 +000025.B \-u
Guido van Rossuma7925f11994-01-26 10:20:16 +000026]
27[
28.B \-v
29]
Guido van Rossum07c44c71998-04-10 19:46:00 +000030[
Guido van Rossumf4a090d2000-09-01 20:36:34 +000031.B \-x
Guido van Rossum4cf4de51997-09-08 04:06:15 +000032]
Barry Warsaw64569372000-09-15 18:39:09 +000033[
34.B \-h
35]
36[
37.B \-V
38]
Guido van Rossum1378c322000-12-19 03:21:54 +000039[
40.B \-W
41.I argument
42]
Guido van Rossum4cf4de51997-09-08 04:06:15 +000043.br
44 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000045.B \-c
46.I command
47|
48.I script
49|
50\-
51]
52[
53.I arguments
54]
55.SH DESCRIPTION
56Python is an interpreted, interactive, object-oriented programming
57language that combines remarkable power with very clear syntax.
58For an introduction to programming in Python you are referred to the
59Python Tutorial.
60The Python Library Reference documents built-in and standard types,
61constants, functions and modules.
62Finally, the Python Reference Manual describes the syntax and
63semantics of the core language in (perhaps too) much detail.
Guido van Rossumf4a090d2000-09-01 20:36:34 +000064(These documents may be located via the
65.B "INTERNET RESOURCES"
Fred Drake4c9be9d1999-08-20 13:10:20 +000066below; they may be installed on your system as well.)
Guido van Rossuma7925f11994-01-26 10:20:16 +000067.PP
68Python's basic power can be extended with your own modules written in
69C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000070On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000071Python is also adaptable as an extension language for existing
72applications.
73See the internal documentation for hints.
Andrew M. Kuchling88717f42001-04-05 14:50:40 +000074.PP
75Documentation for installed Python modules and packages can be
76viewed by running the
77.B pydoc
78program.
Guido van Rossuma7925f11994-01-26 10:20:16 +000079.SH COMMAND LINE OPTIONS
80.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000081.B \-d
82Turn on parser debugging output (for wizards only, depending on
83compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000084.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000085.B \-i
86When a script is passed as first argument or the \fB\-c\fP option is
87used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000088command. It does not read the $PYTHONSTARTUP file. This can be
89useful to inspect global variables or a stack trace when a script
90raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000091.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000092.B \-O
93Turn on basic optimizations. This changes the filename extension for
94compiled (bytecode) files from
95.I .pyc
Fred Drake4c9be9d1999-08-20 13:10:20 +000096to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
Guido van Rossum4cf4de51997-09-08 04:06:15 +000097.TP
98.B \-S
99Disable the import of the module
100.I site
101and the site-dependent manipulations of
102.I sys.path
103that it entails.
104.TP
Neil Schemenauer7d4bb9f2001-07-23 16:30:27 +0000105.B \-E
106Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
107the behavior of the interpreter.
108.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +0000109.B \-t
110Issue a warning when a source file mixes tabs and spaces for
111indentation in a way that makes it depend on the worth of a tab
112expressed in spaces. Issue an error when the option is given twice.
113.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +0000114.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000115Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000116.TP
117.B \-v
118Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +0000119(filename or built-in module) from which it is loaded. When given
120twice, print a message for each file that is checked for when
121searching for a module. Also provides information on module cleanup
122at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000123.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000124.B \-x
125Skip the first line of the source. This is intended for a DOS
126specific hack only. Warning: the line numbers in error messages will
127be off by one!
128.TP
Barry Warsaw64569372000-09-15 18:39:09 +0000129.B \-h
130Prints the usage for the interpreter executable and exits.
131.TP
132.B \-V
133Prints the Python version number of the executable and exits.
134.TP
Guido van Rossum1378c322000-12-19 03:21:54 +0000135.BI "\-W " argument
136Warning control. Python sometimes prints warning message to
137.IR sys.stderr .
138A typical warning message has the following form:
139.IB file ":" line ": " category ": " message.
140By default, each warning is printed once for each source line where it
141occurs. This option controls how often warnings are printed.
142Multiple
143.B \-W
144options may be given; when a warning matches more than one
145option, the action for the last matching option is performed.
146Invalid
147.B \-W
148options are ignored (a warning message is printed about invalid
149options when the first warning is issued). Warnings can also be
150controlled from within a Python program using the
151.I warnings
152module.
153
154The simplest form of
155.I argument
156is one of the following
157.I action
158strings (or a unique abbreviation):
159.B ignore
160to ignore all warnings;
161.B default
162to explicitly request the default behavior (printing each warning once
163per source line);
164.B all
165to print a warning each time it occurs (this may generate many
166messages if a warning is triggered repeatedly for the same source
Fred Drakebd2e3b02001-07-26 21:25:58 +0000167line, such as inside a loop);
Guido van Rossum1378c322000-12-19 03:21:54 +0000168.B module
169to print each warning only only the first time it occurs in each
170module;
171.B once
172to print each warning only the first time it occurs in the program; or
173.B error
174to raise an exception instead of printing a warning message.
175
176The full form of
177.I argument
178is
179.IB action : message : category : module : line.
180Here,
181.I action
182is as explained above but only applies to messages that match the
183remaining fields. Empty fields match all values; trailing empty
184fields may be omitted. The
185.I message
186field matches the start of the warning message printed; this match is
187case-insensitive. The
188.I category
189field matches the warning category. This must be a class name; the
190match test whether the actual warning category of the message is a
191subclass of the specified warning category. The full class name must
192be given. The
193.I module
194field matches the (fully-qualified) module name; this match is
195case-sensitive. The
196.I line
197field matches the line number, where zero matches all line numbers and
198is thus equivalent to an omitted line number.
199.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000200.BI "\-c " command
201Specify the command to execute (see next section).
202This terminates the option list (following options are passed as
203arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000204.SH INTERPRETER INTERFACE
205The interpreter interface resembles that of the UNIX shell: when
206called with standard input connected to a tty device, it prompts for
207commands and executes them until an EOF is read; when called with a
208file name argument or with a file as standard input, it reads and
209executes a
210.I script
211from that file;
212when called with
213.B \-c
214.I command,
215it executes the Python statement(s) given as
216.I command.
217Here
218.I command
219may contain multiple statements separated by newlines.
220Leading whitespace is significant in Python statements!
221In non-interactive mode, the entire input is parsed befored it is
222executed.
223.PP
224If available, the script name and additional arguments thereafter are
225passed to the script in the Python variable
226.I sys.argv ,
227which is a list of strings (you must first
228.I import sys
229to be able to access it).
230If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000231.I sys.argv[0]
232is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000233.B \-c
234is used,
235.I sys.argv[0]
236contains the string
237.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000238Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000239are not placed in
240.I sys.argv.
241.PP
242In interactive mode, the primary prompt is `>>>'; the second prompt
243(which appears when a command is not complete) is `...'.
244The prompts can be changed by assignment to
245.I sys.ps1
246or
247.I sys.ps2.
248The interpreter quits when it reads an EOF at a prompt.
249When an unhandled exception occurs, a stack trace is printed and
250control returns to the primary prompt; in non-interactive mode, the
251interpreter exits after printing the stack trace.
252The interrupt signal raises the
253.I Keyboard\%Interrupt
254exception; other UNIX signals are not caught (except that SIGPIPE is
255sometimes ignored, in favor of the
256.I IOError
257exception). Error messages are written to stderr.
258.SH FILES AND DIRECTORIES
259These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000260conventions; ${prefix} and ${exec_prefix} are installation-dependent
261and should be interpreted as for GNU software; they may be the same.
262The default for both is \fI/usr/local\fP.
263.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000264Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000265.PP
266.I ${prefix}/lib/python<version>
267.br
268.I ${exec_prefix}/lib/python<version>
269.RS
270Recommended locations of the directories containing the standard
271modules.
272.RE
273.PP
274.I ${prefix}/include/python<version>
275.br
276.I ${exec_prefix}/include/python<version>
277.RS
278Recommended locations of the directories containing the include files
279needed for developing Python extensions and embedding the
280interpreter.
281.RE
282.IP \fI~/.pythonrc.py\fP
283User-specific initialization file loaded by the \fIuser\fP module;
284not used by default or by most applications.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000285.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000286.IP PYTHONHOME
287Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000288libraries are searched in ${prefix}/lib/python<version> and
289${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000290are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000291\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
292replaces both ${prefix} and ${exec_prefix}. To specify different values
293for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000294.IP PYTHONPATH
295Augments the default search path for module files.
296The format is the same as the shell's $PATH: one or more directory
297pathnames separated by colons.
298Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000299The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000300begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000301The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000302If a script argument is given, the directory containing the script is
303inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000304The search path can be manipulated from within a Python program as the
305variable
306.I sys.path .
307.IP PYTHONSTARTUP
308If this is the name of a readable file, the Python commands in that
309file are executed before the first prompt is displayed in interactive
310mode.
311The file is executed in the same name space where interactive commands
312are executed so that objects defined or imported in it can be used
313without qualification in the interactive session.
314You can also change the prompts
315.I sys.ps1
316and
317.I sys.ps2
318in this file.
Fred Drakebd2e3b02001-07-26 21:25:58 +0000319.IP PYTHONY2K
320Set this to a non-empty string to cause the \fItime\fP module to
321require dates specified as strings to include 4-digit years, otherwise
3222-digit years are converted based on rules described in the \fItime\fP
323module documnetation.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000324.IP PYTHONDEBUG
325If this is set to a non-empty string it is equivalent to specifying
326the \fB\-d\fP option.
327.IP PYTHONINSPECT
328If this is set to a non-empty string it is equivalent to specifying
329the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000330.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000331If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000332the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000333.IP PYTHONVERBOSE
334If this is set to a non-empty string it is equivalent to specifying
335the \fB\-v\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000336.SH AUTHOR
337.nf
338Guido van Rossum
Guido van Rossuma7925f11994-01-26 10:20:16 +0000339.PP
Guido van Rossum1378c322000-12-19 03:21:54 +0000340E-mail: guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000341.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000342.PP
343And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000344.SH INTERNET RESOURCES
Fred Drakebd2e3b02001-07-26 21:25:58 +0000345Main website: http://www.python.org/
Guido van Rossum74faed21996-07-30 19:27:05 +0000346.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000347Documentation: http://www.python.org/doc/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000348.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000349Community website: http://starship.python.net/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000350.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000351Developer resources: http://sourceforge.net/project/python/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000352.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000353FTP: ftp://ftp.python.org/pub/python/
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000354.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000355Module repository: http://www.vex.net/parnassus/
Guido van Rossum74faed21996-07-30 19:27:05 +0000356.br
Fred Drakebd2e3b02001-07-26 21:25:58 +0000357Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000358.SH LICENSING
359Python is distributed under an Open Source license. See the file
360"LICENSE" in the Python source distribution for information on terms &
361conditions for accessing and otherwise using Python and for a
362DISCLAIMER OF ALL WARRANTIES.