blob: 529046fa106144de1f55541726e8c59288025e26 [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.
71.SH COMMAND LINE OPTIONS
72.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000073.B \-d
74Turn on parser debugging output (for wizards only, depending on
75compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000076.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000077.B \-i
78When a script is passed as first argument or the \fB\-c\fP option is
79used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000080command. It does not read the $PYTHONSTARTUP file. This can be
81useful to inspect global variables or a stack trace when a script
82raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000083.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000084.B \-O
85Turn on basic optimizations. This changes the filename extension for
86compiled (bytecode) files from
87.I .pyc
Fred Drake4c9be9d1999-08-20 13:10:20 +000088to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
Guido van Rossum4cf4de51997-09-08 04:06:15 +000089.TP
90.B \-S
91Disable the import of the module
92.I site
93and the site-dependent manipulations of
94.I sys.path
95that it entails.
96.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +000097.B \-t
98Issue a warning when a source file mixes tabs and spaces for
99indentation in a way that makes it depend on the worth of a tab
100expressed in spaces. Issue an error when the option is given twice.
101.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +0000102.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000103Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000104.TP
105.B \-v
106Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +0000107(filename or built-in module) from which it is loaded. When given
108twice, print a message for each file that is checked for when
109searching for a module. Also provides information on module cleanup
110at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000111.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000112.B \-x
113Skip the first line of the source. This is intended for a DOS
114specific hack only. Warning: the line numbers in error messages will
115be off by one!
116.TP
Barry Warsaw64569372000-09-15 18:39:09 +0000117.B \-h
118Prints the usage for the interpreter executable and exits.
119.TP
120.B \-V
121Prints the Python version number of the executable and exits.
122.TP
Guido van Rossum1378c322000-12-19 03:21:54 +0000123.BI "\-W " argument
124Warning control. Python sometimes prints warning message to
125.IR sys.stderr .
126A typical warning message has the following form:
127.IB file ":" line ": " category ": " message.
128By default, each warning is printed once for each source line where it
129occurs. This option controls how often warnings are printed.
130Multiple
131.B \-W
132options may be given; when a warning matches more than one
133option, the action for the last matching option is performed.
134Invalid
135.B \-W
136options are ignored (a warning message is printed about invalid
137options when the first warning is issued). Warnings can also be
138controlled from within a Python program using the
139.I warnings
140module.
141
142The simplest form of
143.I argument
144is one of the following
145.I action
146strings (or a unique abbreviation):
147.B ignore
148to ignore all warnings;
149.B default
150to explicitly request the default behavior (printing each warning once
151per source line);
152.B all
153to print a warning each time it occurs (this may generate many
154messages if a warning is triggered repeatedly for the same source
155line, e.g. inside a loop);
156.B module
157to print each warning only only the first time it occurs in each
158module;
159.B once
160to print each warning only the first time it occurs in the program; or
161.B error
162to raise an exception instead of printing a warning message.
163
164The full form of
165.I argument
166is
167.IB action : message : category : module : line.
168Here,
169.I action
170is as explained above but only applies to messages that match the
171remaining fields. Empty fields match all values; trailing empty
172fields may be omitted. The
173.I message
174field matches the start of the warning message printed; this match is
175case-insensitive. The
176.I category
177field matches the warning category. This must be a class name; the
178match test whether the actual warning category of the message is a
179subclass of the specified warning category. The full class name must
180be given. The
181.I module
182field matches the (fully-qualified) module name; this match is
183case-sensitive. The
184.I line
185field matches the line number, where zero matches all line numbers and
186is thus equivalent to an omitted line number.
187.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000188.BI "\-c " command
189Specify the command to execute (see next section).
190This terminates the option list (following options are passed as
191arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000192.SH INTERPRETER INTERFACE
193The interpreter interface resembles that of the UNIX shell: when
194called with standard input connected to a tty device, it prompts for
195commands and executes them until an EOF is read; when called with a
196file name argument or with a file as standard input, it reads and
197executes a
198.I script
199from that file;
200when called with
201.B \-c
202.I command,
203it executes the Python statement(s) given as
204.I command.
205Here
206.I command
207may contain multiple statements separated by newlines.
208Leading whitespace is significant in Python statements!
209In non-interactive mode, the entire input is parsed befored it is
210executed.
211.PP
212If available, the script name and additional arguments thereafter are
213passed to the script in the Python variable
214.I sys.argv ,
215which is a list of strings (you must first
216.I import sys
217to be able to access it).
218If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000219.I sys.argv[0]
220is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000221.B \-c
222is used,
223.I sys.argv[0]
224contains the string
225.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000226Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000227are not placed in
228.I sys.argv.
229.PP
230In interactive mode, the primary prompt is `>>>'; the second prompt
231(which appears when a command is not complete) is `...'.
232The prompts can be changed by assignment to
233.I sys.ps1
234or
235.I sys.ps2.
236The interpreter quits when it reads an EOF at a prompt.
237When an unhandled exception occurs, a stack trace is printed and
238control returns to the primary prompt; in non-interactive mode, the
239interpreter exits after printing the stack trace.
240The interrupt signal raises the
241.I Keyboard\%Interrupt
242exception; other UNIX signals are not caught (except that SIGPIPE is
243sometimes ignored, in favor of the
244.I IOError
245exception). Error messages are written to stderr.
246.SH FILES AND DIRECTORIES
247These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000248conventions; ${prefix} and ${exec_prefix} are installation-dependent
249and should be interpreted as for GNU software; they may be the same.
250The default for both is \fI/usr/local\fP.
251.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000252Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000253.PP
254.I ${prefix}/lib/python<version>
255.br
256.I ${exec_prefix}/lib/python<version>
257.RS
258Recommended locations of the directories containing the standard
259modules.
260.RE
261.PP
262.I ${prefix}/include/python<version>
263.br
264.I ${exec_prefix}/include/python<version>
265.RS
266Recommended locations of the directories containing the include files
267needed for developing Python extensions and embedding the
268interpreter.
269.RE
270.IP \fI~/.pythonrc.py\fP
271User-specific initialization file loaded by the \fIuser\fP module;
272not used by default or by most applications.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000273.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000274.IP PYTHONHOME
275Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000276libraries are searched in ${prefix}/lib/python<version> and
277${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000278are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000279\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
280replaces both ${prefix} and ${exec_prefix}. To specify different values
281for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000282.IP PYTHONPATH
283Augments the default search path for module files.
284The format is the same as the shell's $PATH: one or more directory
285pathnames separated by colons.
286Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000287The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000288begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000289The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000290If a script argument is given, the directory containing the script is
291inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000292The search path can be manipulated from within a Python program as the
293variable
294.I sys.path .
295.IP PYTHONSTARTUP
296If this is the name of a readable file, the Python commands in that
297file are executed before the first prompt is displayed in interactive
298mode.
299The file is executed in the same name space where interactive commands
300are executed so that objects defined or imported in it can be used
301without qualification in the interactive session.
302You can also change the prompts
303.I sys.ps1
304and
305.I sys.ps2
306in this file.
307.IP PYTHONDEBUG
308If this is set to a non-empty string it is equivalent to specifying
309the \fB\-d\fP option.
310.IP PYTHONINSPECT
311If this is set to a non-empty string it is equivalent to specifying
312the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000313.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000314If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000315the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000316.IP PYTHONVERBOSE
317If this is set to a non-empty string it is equivalent to specifying
318the \fB\-v\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000319.SH AUTHOR
320.nf
321Guido van Rossum
Guido van Rossuma7925f11994-01-26 10:20:16 +0000322.PP
Guido van Rossum1378c322000-12-19 03:21:54 +0000323E-mail: guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000324.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000325.PP
326And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000327.SH INTERNET RESOURCES
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000328Main website: http://www.python.org
Guido van Rossum74faed21996-07-30 19:27:05 +0000329.br
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000330Community website: http://starship.python.net
331.br
332Developer resources:
333.br
334 http://sourceforge.net/project/?group_id=5470
335.br
336FTP: ftp://ftp.python.org/pub/python
337.br
338Module repository: http://www.vex.net/parnassus/
Guido van Rossum74faed21996-07-30 19:27:05 +0000339.br
Fred Drake4c9be9d1999-08-20 13:10:20 +0000340Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000341.SH LICENSING
342Python is distributed under an Open Source license. See the file
343"LICENSE" in the Python source distribution for information on terms &
344conditions for accessing and otherwise using Python and for a
345DISCLAIMER OF ALL WARRANTIES.