blob: 2747eaedc9a71cb5b2bbad41bf36e77bfdefb51c [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]
30.br
31 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000032.B \-c
33.I command
34|
35.I script
36|
37\-
38]
39[
40.I arguments
41]
42.SH DESCRIPTION
43Python is an interpreted, interactive, object-oriented programming
44language that combines remarkable power with very clear syntax.
45For an introduction to programming in Python you are referred to the
46Python Tutorial.
47The Python Library Reference documents built-in and standard types,
48constants, functions and modules.
49Finally, the Python Reference Manual describes the syntax and
50semantics of the core language in (perhaps too) much detail.
Guido van Rossumf4a090d2000-09-01 20:36:34 +000051(These documents may be located via the
52.B "INTERNET RESOURCES"
Fred Drake4c9be9d1999-08-20 13:10:20 +000053below; they may be installed on your system as well.)
Guido van Rossuma7925f11994-01-26 10:20:16 +000054.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
Fred Drake4c9be9d1999-08-20 13:10:20 +000078to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
Guido van Rossum4cf4de51997-09-08 04:06:15 +000079.TP
80.B \-S
81Disable the import of the module
82.I site
83and the site-dependent manipulations of
84.I sys.path
85that it entails.
86.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +000087.B \-t
88Issue a warning when a source file mixes tabs and spaces for
89indentation in a way that makes it depend on the worth of a tab
90expressed in spaces. Issue an error when the option is given twice.
91.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000092.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +000093Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +000094.TP
95.B \-v
96Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +000097(filename or built-in module) from which it is loaded. When given
98twice, print a message for each file that is checked for when
99searching for a module. Also provides information on module cleanup
100at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000101.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000102.B \-x
103Skip the first line of the source. This is intended for a DOS
104specific hack only. Warning: the line numbers in error messages will
105be off by one!
106.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000107.BI "\-c " command
108Specify the command to execute (see next section).
109This terminates the option list (following options are passed as
110arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000111.SH INTERPRETER INTERFACE
112The interpreter interface resembles that of the UNIX shell: when
113called with standard input connected to a tty device, it prompts for
114commands and executes them until an EOF is read; when called with a
115file name argument or with a file as standard input, it reads and
116executes a
117.I script
118from that file;
119when called with
120.B \-c
121.I command,
122it executes the Python statement(s) given as
123.I command.
124Here
125.I command
126may contain multiple statements separated by newlines.
127Leading whitespace is significant in Python statements!
128In non-interactive mode, the entire input is parsed befored it is
129executed.
130.PP
131If available, the script name and additional arguments thereafter are
132passed to the script in the Python variable
133.I sys.argv ,
134which is a list of strings (you must first
135.I import sys
136to be able to access it).
137If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000138.I sys.argv[0]
139is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000140.B \-c
141is used,
142.I sys.argv[0]
143contains the string
144.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000145Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000146are not placed in
147.I sys.argv.
148.PP
149In interactive mode, the primary prompt is `>>>'; the second prompt
150(which appears when a command is not complete) is `...'.
151The prompts can be changed by assignment to
152.I sys.ps1
153or
154.I sys.ps2.
155The interpreter quits when it reads an EOF at a prompt.
156When an unhandled exception occurs, a stack trace is printed and
157control returns to the primary prompt; in non-interactive mode, the
158interpreter exits after printing the stack trace.
159The interrupt signal raises the
160.I Keyboard\%Interrupt
161exception; other UNIX signals are not caught (except that SIGPIPE is
162sometimes ignored, in favor of the
163.I IOError
164exception). Error messages are written to stderr.
165.SH FILES AND DIRECTORIES
166These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000167conventions; ${prefix} and ${exec_prefix} are installation-dependent
168and should be interpreted as for GNU software; they may be the same.
169The default for both is \fI/usr/local\fP.
170.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000171Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000172.PP
173.I ${prefix}/lib/python<version>
174.br
175.I ${exec_prefix}/lib/python<version>
176.RS
177Recommended locations of the directories containing the standard
178modules.
179.RE
180.PP
181.I ${prefix}/include/python<version>
182.br
183.I ${exec_prefix}/include/python<version>
184.RS
185Recommended locations of the directories containing the include files
186needed for developing Python extensions and embedding the
187interpreter.
188.RE
189.IP \fI~/.pythonrc.py\fP
190User-specific initialization file loaded by the \fIuser\fP module;
191not used by default or by most applications.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000192.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000193.IP PYTHONHOME
194Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000195libraries are searched in ${prefix}/lib/python<version> and
196${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000197are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000198\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
199replaces both ${prefix} and ${exec_prefix}. To specify different values
200for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000201.IP PYTHONPATH
202Augments the default search path for module files.
203The format is the same as the shell's $PATH: one or more directory
204pathnames separated by colons.
205Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000206The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000207begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000208The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000209If a script argument is given, the directory containing the script is
210inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000211The search path can be manipulated from within a Python program as the
212variable
213.I sys.path .
214.IP PYTHONSTARTUP
215If this is the name of a readable file, the Python commands in that
216file are executed before the first prompt is displayed in interactive
217mode.
218The file is executed in the same name space where interactive commands
219are executed so that objects defined or imported in it can be used
220without qualification in the interactive session.
221You can also change the prompts
222.I sys.ps1
223and
224.I sys.ps2
225in this file.
226.IP PYTHONDEBUG
227If this is set to a non-empty string it is equivalent to specifying
228the \fB\-d\fP option.
229.IP PYTHONINSPECT
230If this is set to a non-empty string it is equivalent to specifying
231the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000232.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000233If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000234the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000235.IP PYTHONVERBOSE
236If this is set to a non-empty string it is equivalent to specifying
237the \fB\-v\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000238.SH AUTHOR
239.nf
240Guido van Rossum
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000241BeOpen.com
242160 Saratoga Avenue
243Santa Clara, CA 95051
Guido van Rossum74faed21996-07-30 19:27:05 +0000244USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000245.PP
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000246E-mail: guido@beopen.com, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000247.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000248.PP
249And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000250.SH INTERNET RESOURCES
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000251Main website: http://www.python.org
Guido van Rossum74faed21996-07-30 19:27:05 +0000252.br
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000253BeOpen development team: http://pythonlabs.com
254.br
255Community website: http://starship.python.net
256.br
257Developer resources:
258.br
259 http://sourceforge.net/project/?group_id=5470
260.br
261FTP: ftp://ftp.python.org/pub/python
262.br
263Module repository: http://www.vex.net/parnassus/
Guido van Rossum74faed21996-07-30 19:27:05 +0000264.br
Fred Drake4c9be9d1999-08-20 13:10:20 +0000265Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000266.SH LICENSING
267Python is distributed under an Open Source license. See the file
268"LICENSE" in the Python source distribution for information on terms &
269conditions for accessing and otherwise using Python and for a
270DISCLAIMER OF ALL WARRANTIES.