Allow comment characters (#) to be escaped:
[python/dscho.git] / Misc / python.man
bloba67bcca57904f193e05b4500098dfe43fed5dee4
1 .TH PYTHON "10 April, 1998"
2 .SH NAME
3 python \- an interpreted, interactive, object-oriented programming language
4 .SH SYNOPSIS
5 .B python
7 .B \-d
10 .B \-i
13 .B \-O
16 .B \-S
19 .B \-t
22 .B \-u
25 .B \-v
28 .B \-x
31 .B \-X
33 .br
34        [
35 .B \-c
36 .I command
38 .I script
43 .I arguments
45 .SH DESCRIPTION
46 Python is an interpreted, interactive, object-oriented programming
47 language that combines remarkable power with very clear syntax.
48 For an introduction to programming in Python you are referred to the
49 Python Tutorial.
50 The Python Library Reference documents built-in and standard types,
51 constants, functions and modules.
52 Finally, the Python Reference Manual describes the syntax and
53 semantics of the core language in (perhaps too) much detail.
54 .PP
55 Python's basic power can be extended with your own modules written in
56 C or C++.
57 On most systems such modules may be dynamically loaded.
58 Python is also adaptable as an extension language for existing
59 applications.
60 See the internal documentation for hints.
61 .SH COMMAND LINE OPTIONS
62 .TP
63 .B \-d
64 Turn on parser debugging output (for wizards only, depending on
65 compilation options).
66 .TP
67 .B \-i
68 When a script is passed as first argument or the \fB\-c\fP option is
69 used, enter interactive mode after executing the script or the
70 command.  It does not read the $PYTHONSTARTUP file.  This can be
71 useful to inspect global variables or a stack trace when a script
72 raises an exception.
73 .TP
74 .B \-O
75 Turn on basic optimizations.  This changes the filename extension for
76 compiled (bytecode) files from
77 .I .pyc
79 .I pyo.
80 .TP
81 .B \-S
82 Disable the import of the module
83 .I site
84 and the site-dependent manipulations of
85 .I sys.path
86 that it entails.
87 .TP
88 .B \-t
89 Issue a warning when a source file mixes tabs and spaces for
90 indentation in a way that makes it depend on the worth of a tab
91 expressed in spaces.  Issue an error when the option is given twice.
92 .TP
93 .B \-u
94 Force stdin, stdout and stderr to be totally unbuffered.
95 .TP
96 .B \-v
97 Print a message each time a module is initialized, showing the place
98 (filename or built-in module) from which it is loaded.
99 .TP
100 .B \-x
101 Skip the first line of the source.  This is intended for a DOS
102 specific hack only.  Warning: the line numbers in error messages will
103 be off by one!
105 .B \-X
106 Make the standard exceptions strings instead of classes.
107 Use for backward compatibility with old code only.
109 .BI "\-c " command
110 Specify the command to execute (see next section).
111 This terminates the option list (following options are passed as
112 arguments to the command).
113 .SH INTERPRETER INTERFACE
114 The interpreter interface resembles that of the UNIX shell: when
115 called with standard input connected to a tty device, it prompts for
116 commands and executes them until an EOF is read; when called with a
117 file name argument or with a file as standard input, it reads and
118 executes a
119 .I script
120 from that file;
121 when called with
122 .B \-c
123 .I command,
124 it executes the Python statement(s) given as
125 .I command.
126 Here
127 .I command
128 may contain multiple statements separated by newlines.
129 Leading whitespace is significant in Python statements!
130 In non-interactive mode, the entire input is parsed befored it is
131 executed.
133 If available, the script name and additional arguments thereafter are
134 passed to the script in the Python variable
135 .I sys.argv ,
136 which is a list of strings (you must first
137 .I import sys
138 to be able to access it).
139 If no script name is given,
140 .I sys.argv
141 is empty; if
142 .B \-c
143 is used,
144 .I sys.argv[0]
145 contains the string
146 .I '-c'.
147 Note that options interpreted by the Python interpreter itself
148 are not placed in
149 .I sys.argv.
151 In interactive mode, the primary prompt is `>>>'; the second prompt
152 (which appears when a command is not complete) is `...'.
153 The prompts can be changed by assignment to
154 .I sys.ps1
156 .I sys.ps2.
157 The interpreter quits when it reads an EOF at a prompt.
158 When an unhandled exception occurs, a stack trace is printed and
159 control returns to the primary prompt; in non-interactive mode, the
160 interpreter exits after printing the stack trace.
161 The interrupt signal raises the
162 .I Keyboard\%Interrupt
163 exception; other UNIX signals are not caught (except that SIGPIPE is
164 sometimes ignored, in favor of the
165 .I IOError
166 exception).  Error messages are written to stderr.
167 .SH FILES AND DIRECTORIES
168 These are subject to difference depending on local installation
169 conventions:
170 .IP /usr/local/bin/python
171 Recommended location of the interpreter.
172 .IP /usr/local/lib/python<version>
173 Recommended location of the directory containing the standard modules.
174 .SH ENVIRONMENT VARIABLES
175 .IP PYTHONHOME
176 Change the location of the standard Python libraries.  By default, the
177 libraries are searched in <prefix>/lib/python<version> and
178 <exec_prefix>/lib/python<version>, where <prefix> and <exec_prefix>
179 are installation-dependent directories, both defaulting to
180 /usr/local.  When $PYTHONHOME is set to a single directory, its value
181 replaces both <prefix> and <exec_prefix>.  To specify different values
182 for these, set $PYTHONHOME to <prefix>:<exec_prefix>.
183 .IP PYTHONPATH
184 Augments the default search path for module files.
185 The format is the same as the shell's $PATH: one or more directory
186 pathnames separated by colons.
187 Non-existant directories are silently ignored.
188 The default search path is installation dependent, but generally
189 begins with <prefix>/lib/python<version> (see PYTHONHOME below).
190 The default search path is always appended to $PYTHONPATH.
191 If a script argument is given, the directory containing the script is
192 inserted in the path in front of $PYTHONPATH.
193 The search path can be manipulated from within a Python program as the
194 variable
195 .I sys.path .
196 .IP PYTHONSTARTUP
197 If this is the name of a readable file, the Python commands in that
198 file are executed before the first prompt is displayed in interactive
199 mode.
200 The file is executed in the same name space where interactive commands
201 are executed so that objects defined or imported in it can be used
202 without qualification in the interactive session.
203 You can also change the prompts
204 .I sys.ps1
206 .I sys.ps2
207 in this file.
208 .IP PYTHONDEBUG
209 If this is set to a non-empty string it is equivalent to specifying
210 the \fB\-d\fP option.
211 .IP PYTHONINSPECT
212 If this is set to a non-empty string it is equivalent to specifying
213 the \fB\-i\fP option.
214 .IP PYTHONUNBUFFERED
215 If this is set to a non-empty string it is equivalent to specifying
216 the \fB\-u\fP option.
217 .IP PYTHONVERBOSE
218 If this is set to a non-empty string it is equivalent to specifying
219 the \fB\-v\fP option.
220 .SH SEE ALSO
221 Python Tutorial
223 Python Library Reference
225 Python Reference Manual
226 .SH AUTHOR
228 Guido van Rossum
229 CNRI
230 1895 Preston White Drive
231 Reston, VA 20191
234 E-mail: guido@cnri.reston.va.us, guido@python.org
237 And a cast of thousands.
238 .SH INTERNET RESOURCES
239 Web site: http://www.python.org
241 FTP site: ftp://ftp.python.org
243 Newsgroup: comp.lang.python
244 .SH COPYRIGHT
245 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
246 The Netherlands.
247 .IP " "
248 All Rights Reserved
250 Permission to use, copy, modify, and distribute this software and its
251 documentation for any purpose and without fee is hereby granted,
252 provided that the above copyright notice appear in all copies and that
253 both that copyright notice and this permission notice appear in
254 supporting documentation, and that the names of Stichting Mathematisch
255 Centrum or CWI or Corporation for National Research Initiatives or
256 CNRI not be used in advertising or publicity pertaining to
257 distribution of the software without specific, written prior
258 permission.
260 While CWI is the initial source for this software, a modified version
261 is made available by the Corporation for National Research Initiatives
262 (CNRI) at the Internet address ftp://ftp.python.org.
264 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
265 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
266 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
267 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
268 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
269 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
270 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
271 PERFORMANCE OF THIS SOFTWARE.