This commit was manufactured by cvs2svn to create tag 'r22a4-fork'.
[python/dscho.git] / Misc / python.man
blob6723e13b2e0f7e839bfac0b677c45e4cf3767649
1 .TH PYTHON "1" "$Date$"
2 .SH NAME
3 python \- an interpreted, interactive, object-oriented programming language
4 .SH SYNOPSIS
5 .B python
7 .B \-d
10 .B \-E
13 .B \-h
16 .B \-i
19 .B \-O
21 .br
22        [
23 .B -Q
24 .I argument
27 .B \-S
30 .B \-t
33 .B \-u
36 .B \-U
38 .br
39        [
40 .B \-v
43 .B \-V
46 .B \-W
47 .I argument
50 .B \-x
52 .br
53        [
54 .B \-c
55 .I command
57 .I script
62 .I arguments
64 .SH DESCRIPTION
65 Python is an interpreted, interactive, object-oriented programming
66 language that combines remarkable power with very clear syntax.
67 For an introduction to programming in Python you are referred to the
68 Python Tutorial.
69 The Python Library Reference documents built-in and standard types,
70 constants, functions and modules.
71 Finally, the Python Reference Manual describes the syntax and
72 semantics of the core language in (perhaps too) much detail.
73 (These documents may be located via the
74 .B "INTERNET RESOURCES"
75 below; they may be installed on your system as well.)
76 .PP
77 Python's basic power can be extended with your own modules written in
78 C or C++.
79 On most systems such modules may be dynamically loaded.
80 Python is also adaptable as an extension language for existing
81 applications.
82 See the internal documentation for hints.
83 .PP
84 Documentation for installed Python modules and packages can be 
85 viewed by running the 
86 .B pydoc
87 program.  
88 .SH COMMAND LINE OPTIONS
89 .TP
90 .BI "\-c " command
91 Specify the command to execute (see next section).
92 This terminates the option list (following options are passed as
93 arguments to the command).
94 .TP
95 .B \-d
96 Turn on parser debugging output (for wizards only, depending on
97 compilation options).
98 .TP
99 .B \-E
100 Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
101 the behavior of the interpreter.
103 .B \-h
104 Prints the usage for the interpreter executable and exits.
106 .B \-i
107 When a script is passed as first argument or the \fB\-c\fP option is
108 used, enter interactive mode after executing the script or the
109 command.  It does not read the $PYTHONSTARTUP file.  This can be
110 useful to inspect global variables or a stack trace when a script
111 raises an exception.
113 .B \-O
114 Turn on basic optimizations.  This changes the filename extension for
115 compiled (bytecode) files from
116 .I .pyc
117 to \fI.pyo\fP.  Given twice, causes docstrings to be discarded.
119 .BI "\-Q " argument
120 Division control; see PEP 238.  The argument must be one of "old" (the
121 default, int/int and long/long return an int or long), "new" (new
122 division semantics, i.e. int/int and long/long returns a float),
123 "warn" (old division semantics with a warning for int/int and
124 long/long), or "warnall" (old division semantics with a warning for
125 all use of the division operator).  For a use of "warnall", see the
126 Tools/scripts/fixdiv.py script.
128 .B \-S
129 Disable the import of the module
130 .I site
131 and the site-dependent manipulations of
132 .I sys.path
133 that it entails.
135 .B \-t
136 Issue a warning when a source file mixes tabs and spaces for
137 indentation in a way that makes it depend on the worth of a tab
138 expressed in spaces.  Issue an error when the option is given twice.
140 .B \-u
141 Force stdin, stdout and stderr to be totally unbuffered.
143 .B \-v
144 Print a message each time a module is initialized, showing the place
145 (filename or built-in module) from which it is loaded.  When given
146 twice, print a message for each file that is checked for when 
147 searching for a module.  Also provides information on module cleanup
148 at exit.
150 .B \-V
151 Prints the Python version number of the executable and exits.
153 .BI "\-W " argument
154 Warning control.  Python sometimes prints warning message to
155 .IR sys.stderr .
156 A typical warning message has the following form:
157 .IB file ":" line ": " category ": " message.
158 By default, each warning is printed once for each source line where it
159 occurs.  This option controls how often warnings are printed.
160 Multiple
161 .B \-W
162 options may be given; when a warning matches more than one
163 option, the action for the last matching option is performed.
164 Invalid
165 .B \-W
166 options are ignored (a warning message is printed about invalid
167 options when the first warning is issued).  Warnings can also be
168 controlled from within a Python program using the
169 .I warnings
170 module.
172 The simplest form of
173 .I argument
174 is one of the following
175 .I action
176 strings (or a unique abbreviation):
177 .B ignore
178 to ignore all warnings;
179 .B default
180 to explicitly request the default behavior (printing each warning once
181 per source line);
182 .B all
183 to print a warning each time it occurs (this may generate many
184 messages if a warning is triggered repeatedly for the same source
185 line, such as inside a loop);
186 .B module
187 to print each warning only only the first time it occurs in each
188 module;
189 .B once
190 to print each warning only the first time it occurs in the program; or
191 .B error
192 to raise an exception instead of printing a warning message.
194 The full form of
195 .I argument
197 .IB action : message : category : module : line.
198 Here,
199 .I action
200 is as explained above but only applies to messages that match the
201 remaining fields.  Empty fields match all values; trailing empty
202 fields may be omitted.  The
203 .I message
204 field matches the start of the warning message printed; this match is
205 case-insensitive.  The
206 .I category
207 field matches the warning category.  This must be a class name; the
208 match test whether the actual warning category of the message is a
209 subclass of the specified warning category.  The full class name must
210 be given.  The
211 .I module
212 field matches the (fully-qualified) module name; this match is
213 case-sensitive.  The
214 .I line
215 field matches the line number, where zero matches all line numbers and
216 is thus equivalent to an omitted line number.
218 .B \-x
219 Skip the first line of the source.  This is intended for a DOS
220 specific hack only.  Warning: the line numbers in error messages will
221 be off by one!
222 .SH INTERPRETER INTERFACE
223 The interpreter interface resembles that of the UNIX shell: when
224 called with standard input connected to a tty device, it prompts for
225 commands and executes them until an EOF is read; when called with a
226 file name argument or with a file as standard input, it reads and
227 executes a
228 .I script
229 from that file;
230 when called with
231 .B \-c
232 .I command,
233 it executes the Python statement(s) given as
234 .I command.
235 Here
236 .I command
237 may contain multiple statements separated by newlines.
238 Leading whitespace is significant in Python statements!
239 In non-interactive mode, the entire input is parsed befored it is
240 executed.
242 If available, the script name and additional arguments thereafter are
243 passed to the script in the Python variable
244 .I sys.argv ,
245 which is a list of strings (you must first
246 .I import sys
247 to be able to access it).
248 If no script name is given,
249 .I sys.argv[0]
250 is an empty string; if
251 .B \-c
252 is used,
253 .I sys.argv[0]
254 contains the string
255 .I '-c'.
256 Note that options interpreted by the Python interpreter itself
257 are not placed in
258 .I sys.argv.
260 In interactive mode, the primary prompt is `>>>'; the second prompt
261 (which appears when a command is not complete) is `...'.
262 The prompts can be changed by assignment to
263 .I sys.ps1
265 .I sys.ps2.
266 The interpreter quits when it reads an EOF at a prompt.
267 When an unhandled exception occurs, a stack trace is printed and
268 control returns to the primary prompt; in non-interactive mode, the
269 interpreter exits after printing the stack trace.
270 The interrupt signal raises the
271 .I Keyboard\%Interrupt
272 exception; other UNIX signals are not caught (except that SIGPIPE is
273 sometimes ignored, in favor of the
274 .I IOError
275 exception).  Error messages are written to stderr.
276 .SH FILES AND DIRECTORIES
277 These are subject to difference depending on local installation
278 conventions; ${prefix} and ${exec_prefix} are installation-dependent
279 and should be interpreted as for GNU software; they may be the same.
280 The default for both is \fI/usr/local\fP.
281 .IP \fI${exec_prefix}/bin/python\fP
282 Recommended location of the interpreter.
284 .I ${prefix}/lib/python<version>
286 .I ${exec_prefix}/lib/python<version>
288 Recommended locations of the directories containing the standard
289 modules.
292 .I ${prefix}/include/python<version>
294 .I ${exec_prefix}/include/python<version>
296 Recommended locations of the directories containing the include files
297 needed for developing Python extensions and embedding the
298 interpreter.
300 .IP \fI~/.pythonrc.py\fP
301 User-specific initialization file loaded by the \fIuser\fP module;
302 not used by default or by most applications.
303 .SH ENVIRONMENT VARIABLES
304 .IP PYTHONHOME
305 Change the location of the standard Python libraries.  By default, the
306 libraries are searched in ${prefix}/lib/python<version> and
307 ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
308 are installation-dependent directories, both defaulting to
309 \fI/usr/local\fP.  When $PYTHONHOME is set to a single directory, its value
310 replaces both ${prefix} and ${exec_prefix}.  To specify different values
311 for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
312 .IP PYTHONPATH
313 Augments the default search path for module files.
314 The format is the same as the shell's $PATH: one or more directory
315 pathnames separated by colons.
316 Non-existant directories are silently ignored.
317 The default search path is installation dependent, but generally
318 begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
319 The default search path is always appended to $PYTHONPATH.
320 If a script argument is given, the directory containing the script is
321 inserted in the path in front of $PYTHONPATH.
322 The search path can be manipulated from within a Python program as the
323 variable
324 .I sys.path .
325 .IP PYTHONSTARTUP
326 If this is the name of a readable file, the Python commands in that
327 file are executed before the first prompt is displayed in interactive
328 mode.
329 The file is executed in the same name space where interactive commands
330 are executed so that objects defined or imported in it can be used
331 without qualification in the interactive session.
332 You can also change the prompts
333 .I sys.ps1
335 .I sys.ps2
336 in this file.
337 .IP PYTHONY2K
338 Set this to a non-empty string to cause the \fItime\fP module to
339 require dates specified as strings to include 4-digit years, otherwise
340 2-digit years are converted based on rules described in the \fItime\fP
341 module documnetation.
342 .IP PYTHONDEBUG
343 If this is set to a non-empty string it is equivalent to specifying
344 the \fB\-d\fP option.
345 .IP PYTHONINSPECT
346 If this is set to a non-empty string it is equivalent to specifying
347 the \fB\-i\fP option.
348 .IP PYTHONUNBUFFERED
349 If this is set to a non-empty string it is equivalent to specifying
350 the \fB\-u\fP option.
351 .IP PYTHONVERBOSE
352 If this is set to a non-empty string it is equivalent to specifying
353 the \fB\-v\fP option.
354 .SH AUTHOR
356 Guido van Rossum
358 E-mail: guido@python.org
361 And a cast of thousands.
362 .SH INTERNET RESOURCES
363 Main website:  http://www.python.org/
365 Documentation:  http://www.python.org/doc/
367 Community website:  http://starship.python.net/
369 Developer resources:  http://sourceforge.net/project/python/
371 FTP:  ftp://ftp.python.org/pub/python/
373 Module repository:  http://www.vex.net/parnassus/
375 Newsgroups:  comp.lang.python, comp.lang.python.announce
376 .SH LICENSING
377 Python is distributed under an Open Source license.  See the file
378 "LICENSE" in the Python source distribution for information on terms &
379 conditions for accessing and otherwise using Python and for a
380 DISCLAIMER OF ALL WARRANTIES.