blob: a23ae0ea16f82566b603418c96e0425416299fc5 [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 Rossum4cf4de51997-09-08 04:06:15 +000036.br
37 [
Guido van Rossuma7925f11994-01-26 10:20:16 +000038.B \-c
39.I command
40|
41.I script
42|
43\-
44]
45[
46.I arguments
47]
48.SH DESCRIPTION
49Python is an interpreted, interactive, object-oriented programming
50language that combines remarkable power with very clear syntax.
51For an introduction to programming in Python you are referred to the
52Python Tutorial.
53The Python Library Reference documents built-in and standard types,
54constants, functions and modules.
55Finally, the Python Reference Manual describes the syntax and
56semantics of the core language in (perhaps too) much detail.
Guido van Rossumf4a090d2000-09-01 20:36:34 +000057(These documents may be located via the
58.B "INTERNET RESOURCES"
Fred Drake4c9be9d1999-08-20 13:10:20 +000059below; they may be installed on your system as well.)
Guido van Rossuma7925f11994-01-26 10:20:16 +000060.PP
61Python's basic power can be extended with your own modules written in
62C or C++.
Guido van Rossum74faed21996-07-30 19:27:05 +000063On most systems such modules may be dynamically loaded.
Guido van Rossuma7925f11994-01-26 10:20:16 +000064Python is also adaptable as an extension language for existing
65applications.
66See the internal documentation for hints.
67.SH COMMAND LINE OPTIONS
68.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000069.B \-d
70Turn on parser debugging output (for wizards only, depending on
71compilation options).
Guido van Rossum9f65ae01994-02-23 09:10:27 +000072.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +000073.B \-i
74When a script is passed as first argument or the \fB\-c\fP option is
75used, enter interactive mode after executing the script or the
Guido van Rossum9f65ae01994-02-23 09:10:27 +000076command. It does not read the $PYTHONSTARTUP file. This can be
77useful to inspect global variables or a stack trace when a script
78raises an exception.
Guido van Rossuma7925f11994-01-26 10:20:16 +000079.TP
Guido van Rossum4cf4de51997-09-08 04:06:15 +000080.B \-O
81Turn on basic optimizations. This changes the filename extension for
82compiled (bytecode) files from
83.I .pyc
Fred Drake4c9be9d1999-08-20 13:10:20 +000084to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
Guido van Rossum4cf4de51997-09-08 04:06:15 +000085.TP
86.B \-S
87Disable the import of the module
88.I site
89and the site-dependent manipulations of
90.I sys.path
91that it entails.
92.TP
Guido van Rossum29d465b1998-04-10 19:36:09 +000093.B \-t
94Issue a warning when a source file mixes tabs and spaces for
95indentation in a way that makes it depend on the worth of a tab
96expressed in spaces. Issue an error when the option is given twice.
97.TP
Guido van Rossumef5bca31994-05-03 14:15:32 +000098.B \-u
Guido van Rossum4cf4de51997-09-08 04:06:15 +000099Force stdin, stdout and stderr to be totally unbuffered.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000100.TP
101.B \-v
102Print a message each time a module is initialized, showing the place
Fred Drake4c9be9d1999-08-20 13:10:20 +0000103(filename or built-in module) from which it is loaded. When given
104twice, print a message for each file that is checked for when
105searching for a module. Also provides information on module cleanup
106at exit.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000107.TP
Guido van Rossum07c44c71998-04-10 19:46:00 +0000108.B \-x
109Skip the first line of the source. This is intended for a DOS
110specific hack only. Warning: the line numbers in error messages will
111be off by one!
112.TP
Barry Warsaw64569372000-09-15 18:39:09 +0000113.B \-h
114Prints the usage for the interpreter executable and exits.
115.TP
116.B \-V
117Prints the Python version number of the executable and exits.
118.TP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000119.BI "\-c " command
120Specify the command to execute (see next section).
121This terminates the option list (following options are passed as
122arguments to the command).
Guido van Rossuma7925f11994-01-26 10:20:16 +0000123.SH INTERPRETER INTERFACE
124The interpreter interface resembles that of the UNIX shell: when
125called with standard input connected to a tty device, it prompts for
126commands and executes them until an EOF is read; when called with a
127file name argument or with a file as standard input, it reads and
128executes a
129.I script
130from that file;
131when called with
132.B \-c
133.I command,
134it executes the Python statement(s) given as
135.I command.
136Here
137.I command
138may contain multiple statements separated by newlines.
139Leading whitespace is significant in Python statements!
140In non-interactive mode, the entire input is parsed befored it is
141executed.
142.PP
143If available, the script name and additional arguments thereafter are
144passed to the script in the Python variable
145.I sys.argv ,
146which is a list of strings (you must first
147.I import sys
148to be able to access it).
149If no script name is given,
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000150.I sys.argv[0]
151is an empty string; if
Guido van Rossuma7925f11994-01-26 10:20:16 +0000152.B \-c
153is used,
154.I sys.argv[0]
155contains the string
156.I '-c'.
Guido van Rossum74faed21996-07-30 19:27:05 +0000157Note that options interpreted by the Python interpreter itself
Guido van Rossuma7925f11994-01-26 10:20:16 +0000158are not placed in
159.I sys.argv.
160.PP
161In interactive mode, the primary prompt is `>>>'; the second prompt
162(which appears when a command is not complete) is `...'.
163The prompts can be changed by assignment to
164.I sys.ps1
165or
166.I sys.ps2.
167The interpreter quits when it reads an EOF at a prompt.
168When an unhandled exception occurs, a stack trace is printed and
169control returns to the primary prompt; in non-interactive mode, the
170interpreter exits after printing the stack trace.
171The interrupt signal raises the
172.I Keyboard\%Interrupt
173exception; other UNIX signals are not caught (except that SIGPIPE is
174sometimes ignored, in favor of the
175.I IOError
176exception). Error messages are written to stderr.
177.SH FILES AND DIRECTORIES
178These are subject to difference depending on local installation
Fred Drake4c9be9d1999-08-20 13:10:20 +0000179conventions; ${prefix} and ${exec_prefix} are installation-dependent
180and should be interpreted as for GNU software; they may be the same.
181The default for both is \fI/usr/local\fP.
182.IP \fI${exec_prefix}/bin/python\fP
Guido van Rossuma7925f11994-01-26 10:20:16 +0000183Recommended location of the interpreter.
Fred Drake4c9be9d1999-08-20 13:10:20 +0000184.PP
185.I ${prefix}/lib/python<version>
186.br
187.I ${exec_prefix}/lib/python<version>
188.RS
189Recommended locations of the directories containing the standard
190modules.
191.RE
192.PP
193.I ${prefix}/include/python<version>
194.br
195.I ${exec_prefix}/include/python<version>
196.RS
197Recommended locations of the directories containing the include files
198needed for developing Python extensions and embedding the
199interpreter.
200.RE
201.IP \fI~/.pythonrc.py\fP
202User-specific initialization file loaded by the \fIuser\fP module;
203not used by default or by most applications.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000204.SH ENVIRONMENT VARIABLES
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000205.IP PYTHONHOME
206Change the location of the standard Python libraries. By default, the
Fred Drake4c9be9d1999-08-20 13:10:20 +0000207libraries are searched in ${prefix}/lib/python<version> and
208${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000209are installation-dependent directories, both defaulting to
Fred Drake4c9be9d1999-08-20 13:10:20 +0000210\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
211replaces both ${prefix} and ${exec_prefix}. To specify different values
212for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000213.IP PYTHONPATH
214Augments the default search path for module files.
215The format is the same as the shell's $PATH: one or more directory
216pathnames separated by colons.
217Non-existant directories are silently ignored.
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000218The default search path is installation dependent, but generally
Fred Drake4c9be9d1999-08-20 13:10:20 +0000219begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000220The default search path is always appended to $PYTHONPATH.
Guido van Rossum74faed21996-07-30 19:27:05 +0000221If a script argument is given, the directory containing the script is
222inserted in the path in front of $PYTHONPATH.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000223The search path can be manipulated from within a Python program as the
224variable
225.I sys.path .
226.IP PYTHONSTARTUP
227If this is the name of a readable file, the Python commands in that
228file are executed before the first prompt is displayed in interactive
229mode.
230The file is executed in the same name space where interactive commands
231are executed so that objects defined or imported in it can be used
232without qualification in the interactive session.
233You can also change the prompts
234.I sys.ps1
235and
236.I sys.ps2
237in this file.
238.IP PYTHONDEBUG
239If this is set to a non-empty string it is equivalent to specifying
240the \fB\-d\fP option.
241.IP PYTHONINSPECT
242If this is set to a non-empty string it is equivalent to specifying
243the \fB\-i\fP option.
Guido van Rossumef5bca31994-05-03 14:15:32 +0000244.IP PYTHONUNBUFFERED
Guido van Rossuma7925f11994-01-26 10:20:16 +0000245If this is set to a non-empty string it is equivalent to specifying
Guido van Rossumef5bca31994-05-03 14:15:32 +0000246the \fB\-u\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000247.IP PYTHONVERBOSE
248If this is set to a non-empty string it is equivalent to specifying
249the \fB\-v\fP option.
Guido van Rossuma7925f11994-01-26 10:20:16 +0000250.SH AUTHOR
251.nf
252Guido van Rossum
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000253BeOpen.com
254160 Saratoga Avenue
255Santa Clara, CA 95051
Guido van Rossum74faed21996-07-30 19:27:05 +0000256USA
Guido van Rossuma7925f11994-01-26 10:20:16 +0000257.PP
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000258E-mail: guido@beopen.com, guido@python.org
Guido van Rossuma7925f11994-01-26 10:20:16 +0000259.fi
Guido van Rossum4cf4de51997-09-08 04:06:15 +0000260.PP
261And a cast of thousands.
Guido van Rossum74faed21996-07-30 19:27:05 +0000262.SH INTERNET RESOURCES
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000263Main website: http://www.python.org
Guido van Rossum74faed21996-07-30 19:27:05 +0000264.br
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000265BeOpen development team: http://pythonlabs.com
266.br
267Community website: http://starship.python.net
268.br
269Developer resources:
270.br
271 http://sourceforge.net/project/?group_id=5470
272.br
273FTP: ftp://ftp.python.org/pub/python
274.br
275Module repository: http://www.vex.net/parnassus/
Guido van Rossum74faed21996-07-30 19:27:05 +0000276.br
Fred Drake4c9be9d1999-08-20 13:10:20 +0000277Newsgroups: comp.lang.python, comp.lang.python.announce
Guido van Rossumf4a090d2000-09-01 20:36:34 +0000278.SH LICENSING
279Python is distributed under an Open Source license. See the file
280"LICENSE" in the Python source distribution for information on terms &
281conditions for accessing and otherwise using Python and for a
282DISCLAIMER OF ALL WARRANTIES.