1 .TH PYTHON "1" "$Date$"
3 .\" To view this file while editing, run it through groff:
4 .\" groff -Tascii -man python.man | less
7 python \- an interpreted, interactive, object-oriented programming language
67 Python is an interpreted, interactive, object-oriented programming
68 language that combines remarkable power with very clear syntax.
69 For an introduction to programming in Python you are referred to the
71 The Python Library Reference documents built-in and standard types,
72 constants, functions and modules.
73 Finally, the Python Reference Manual describes the syntax and
74 semantics of the core language in (perhaps too) much detail.
75 (These documents may be located via the
76 .B "INTERNET RESOURCES"
77 below; they may be installed on your system as well.)
79 Python's basic power can be extended with your own modules written in
81 On most systems such modules may be dynamically loaded.
82 Python is also adaptable as an extension language for existing
84 See the internal documentation for hints.
86 Documentation for installed Python modules and packages can be
90 .SH COMMAND LINE OPTIONS
93 Specify the command to execute (see next section).
94 This terminates the option list (following options are passed as
95 arguments to the command).
98 Turn on parser debugging output (for wizards only, depending on
102 Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
103 the behavior of the interpreter.
106 Prints the usage for the interpreter executable and exits.
109 When a script is passed as first argument or the \fB\-c\fP option is
110 used, enter interactive mode after executing the script or the
111 command. It does not read the $PYTHONSTARTUP file. This can be
112 useful to inspect global variables or a stack trace when a script
115 .BI "\-m " module-name
118 for the named module and runs the corresponding
123 Turn on basic optimizations. This changes the filename extension for
124 compiled (bytecode) files from
126 to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
129 Division control; see PEP 238. The argument must be one of "old" (the
130 default, int/int and long/long return an int or long), "new" (new
131 division semantics, i.e. int/int and long/long returns a float),
132 "warn" (old division semantics with a warning for int/int and
133 long/long), or "warnall" (old division semantics with a warning for
134 all use of the division operator). For a use of "warnall", see the
135 Tools/scripts/fixdiv.py script.
138 Disable the import of the module
140 and the site-dependent manipulations of
145 Force stdin, stdout and stderr to be totally unbuffered. On systems
146 where it matters, also put stdin, stdout and stderr in binary mode.
147 Note that there is internal buffering in readlines() and
148 file-object iterators ("for line in sys.stdin") which is not
149 influenced by this option. To work around this, you will want to use
150 "sys.stdin.readline()" inside a "while 1:" loop.
153 Print a message each time a module is initialized, showing the place
154 (filename or built-in module) from which it is loaded. When given
155 twice, print a message for each file that is checked for when
156 searching for a module. Also provides information on module cleanup
160 Prints the Python version number of the executable and exits.
163 Warning control. Python sometimes prints warning message to
165 A typical warning message has the following form:
166 .IB file ":" line ": " category ": " message.
167 By default, each warning is printed once for each source line where it
168 occurs. This option controls how often warnings are printed.
171 options may be given; when a warning matches more than one
172 option, the action for the last matching option is performed.
175 options are ignored (a warning message is printed about invalid
176 options when the first warning is issued). Warnings can also be
177 controlled from within a Python program using the
183 is one of the following
185 strings (or a unique abbreviation):
187 to ignore all warnings;
189 to explicitly request the default behavior (printing each warning once
192 to print a warning each time it occurs (this may generate many
193 messages if a warning is triggered repeatedly for the same source
194 line, such as inside a loop);
196 to print each warning only only the first time it occurs in each
199 to print each warning only the first time it occurs in the program; or
201 to raise an exception instead of printing a warning message.
206 .IB action : message : category : module : line.
209 is as explained above but only applies to messages that match the
210 remaining fields. Empty fields match all values; trailing empty
211 fields may be omitted. The
213 field matches the start of the warning message printed; this match is
214 case-insensitive. The
216 field matches the warning category. This must be a class name; the
217 match test whether the actual warning category of the message is a
218 subclass of the specified warning category. The full class name must
221 field matches the (fully-qualified) module name; this match is
224 field matches the line number, where zero matches all line numbers and
225 is thus equivalent to an omitted line number.
228 Skip the first line of the source. This is intended for a DOS
229 specific hack only. Warning: the line numbers in error messages will
231 .SH INTERPRETER INTERFACE
232 The interpreter interface resembles that of the UNIX shell: when
233 called with standard input connected to a tty device, it prompts for
234 commands and executes them until an EOF is read; when called with a
235 file name argument or with a file as standard input, it reads and
242 it executes the Python statement(s) given as
246 may contain multiple statements separated by newlines.
247 Leading whitespace is significant in Python statements!
248 In non-interactive mode, the entire input is parsed before it is
251 If available, the script name and additional arguments thereafter are
252 passed to the script in the Python variable
254 which is a list of strings (you must first
256 to be able to access it).
257 If no script name is given,
259 is an empty string; if
265 Note that options interpreted by the Python interpreter itself
269 In interactive mode, the primary prompt is `>>>'; the second prompt
270 (which appears when a command is not complete) is `...'.
271 The prompts can be changed by assignment to
275 The interpreter quits when it reads an EOF at a prompt.
276 When an unhandled exception occurs, a stack trace is printed and
277 control returns to the primary prompt; in non-interactive mode, the
278 interpreter exits after printing the stack trace.
279 The interrupt signal raises the
280 .I Keyboard\%Interrupt
281 exception; other UNIX signals are not caught (except that SIGPIPE is
282 sometimes ignored, in favor of the
284 exception). Error messages are written to stderr.
285 .SH FILES AND DIRECTORIES
286 These are subject to difference depending on local installation
287 conventions; ${prefix} and ${exec_prefix} are installation-dependent
288 and should be interpreted as for GNU software; they may be the same.
289 The default for both is \fI/usr/local\fP.
290 .IP \fI${exec_prefix}/bin/python\fP
291 Recommended location of the interpreter.
293 .I ${prefix}/lib/python<version>
295 .I ${exec_prefix}/lib/python<version>
297 Recommended locations of the directories containing the standard
301 .I ${prefix}/include/python<version>
303 .I ${exec_prefix}/include/python<version>
305 Recommended locations of the directories containing the include files
306 needed for developing Python extensions and embedding the
309 .SH ENVIRONMENT VARIABLES
311 Change the location of the standard Python libraries. By default, the
312 libraries are searched in ${prefix}/lib/python<version> and
313 ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
314 are installation-dependent directories, both defaulting to
315 \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
316 replaces both ${prefix} and ${exec_prefix}. To specify different values
317 for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
319 Augments the default search path for module files.
320 The format is the same as the shell's $PATH: one or more directory
321 pathnames separated by colons.
322 Non-existent directories are silently ignored.
323 The default search path is installation dependent, but generally
324 begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
325 The default search path is always appended to $PYTHONPATH.
326 If a script argument is given, the directory containing the script is
327 inserted in the path in front of $PYTHONPATH.
328 The search path can be manipulated from within a Python program as the
332 If this is the name of a readable file, the Python commands in that
333 file are executed before the first prompt is displayed in interactive
335 The file is executed in the same name space where interactive commands
336 are executed so that objects defined or imported in it can be used
337 without qualification in the interactive session.
338 You can also change the prompts
344 Set this to a non-empty string to cause the \fItime\fP module to
345 require dates specified as strings to include 4-digit years, otherwise
346 2-digit years are converted based on rules described in the \fItime\fP
347 module documentation.
349 If this is set to a non-empty string it is equivalent to specifying
350 the \fB\-O\fP option. If set to an integer, it is equivalent to
351 specifying \fB\-O\fP multiple times.
353 If this is set to a non-empty string it is equivalent to specifying
354 the \fB\-d\fP option. If set to an integer, it is equivalent to
355 specifying \fB\-d\fP multiple times.
357 If this is set to a non-empty string it is equivalent to specifying
358 the \fB\-i\fP option.
360 If this is set to a non-empty string it is equivalent to specifying
361 the \fB\-u\fP option.
363 If this is set to a non-empty string it is equivalent to specifying
364 the \fB\-v\fP option. If set to an integer, it is equivalent to
365 specifying \fB\-v\fP multiple times.
367 The Python Software Foundation: http://www.python.org/psf
368 .SH INTERNET RESOURCES
369 Main website: http://www.python.org/
371 Documentation: http://docs.python.org/
373 Community website: http://starship.python.net/
375 Developer resources: http://www.python.org/dev/
377 FTP: ftp://ftp.python.org/pub/python/
379 Module repository: http://www.vex.net/parnassus/
381 Newsgroups: comp.lang.python, comp.lang.python.announce
383 Python is distributed under an Open Source license. See the file
384 "LICENSE" in the Python source distribution for information on terms &
385 conditions for accessing and otherwise using Python and for a
386 DISCLAIMER OF ALL WARRANTIES.