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
70 Python is an interpreted, interactive, object-oriented programming
71 language that combines remarkable power with very clear syntax.
72 For an introduction to programming in Python you are referred to the
74 The Python Library Reference documents built-in and standard types,
75 constants, functions and modules.
76 Finally, the Python Reference Manual describes the syntax and
77 semantics of the core language in (perhaps too) much detail.
78 (These documents may be located via the
79 .B "INTERNET RESOURCES"
80 below; they may be installed on your system as well.)
82 Python's basic power can be extended with your own modules written in
84 On most systems such modules may be dynamically loaded.
85 Python is also adaptable as an extension language for existing
87 See the internal documentation for hints.
89 Documentation for installed Python modules and packages can be
93 .SH COMMAND LINE OPTIONS
96 Specify the command to execute (see next section).
97 This terminates the option list (following options are passed as
98 arguments to the command).
101 Turn on parser debugging output (for wizards only, depending on
102 compilation options).
105 Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
106 the behavior of the interpreter.
109 Prints the usage for the interpreter executable and exits.
112 When a script is passed as first argument or the \fB\-c\fP option is
113 used, enter interactive mode after executing the script or the
114 command. It does not read the $PYTHONSTARTUP file. This can be
115 useful to inspect global variables or a stack trace when a script
118 .BI "\-m " module-name
121 for the named module and runs the corresponding
126 Turn on basic optimizations. This changes the filename extension for
127 compiled (bytecode) files from
129 to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
132 Division control; see PEP 238. The argument must be one of "old" (the
133 default, int/int and long/long return an int or long), "new" (new
134 division semantics, i.e. int/int and long/long returns a float),
135 "warn" (old division semantics with a warning for int/int and
136 long/long), or "warnall" (old division semantics with a warning for
137 all use of the division operator). For a use of "warnall", see the
138 Tools/scripts/fixdiv.py script.
141 Disable the import of the module
143 and the site-dependent manipulations of
148 Issue a warning when a source file mixes tabs and spaces for
149 indentation in a way that makes it depend on the worth of a tab
150 expressed in spaces. Issue an error when the option is given twice.
153 Force stdin, stdout and stderr to be totally unbuffered. On systems
154 where it matters, also put stdin, stdout and stderr in binary mode.
155 Note that there is internal buffering in xreadlines(), readlines() and
156 file-object iterators ("for line in sys.stdin") which is not
157 influenced by this option. To work around this, you will want to use
158 "sys.stdin.readline()" inside a "while 1:" loop.
161 Print a message each time a module is initialized, showing the place
162 (filename or built-in module) from which it is loaded. When given
163 twice, print a message for each file that is checked for when
164 searching for a module. Also provides information on module cleanup
168 Prints the Python version number of the executable and exits.
171 Warning control. Python sometimes prints warning message to
173 A typical warning message has the following form:
174 .IB file ":" line ": " category ": " message.
175 By default, each warning is printed once for each source line where it
176 occurs. This option controls how often warnings are printed.
179 options may be given; when a warning matches more than one
180 option, the action for the last matching option is performed.
183 options are ignored (a warning message is printed about invalid
184 options when the first warning is issued). Warnings can also be
185 controlled from within a Python program using the
191 is one of the following
193 strings (or a unique abbreviation):
195 to ignore all warnings;
197 to explicitly request the default behavior (printing each warning once
200 to print a warning each time it occurs (this may generate many
201 messages if a warning is triggered repeatedly for the same source
202 line, such as inside a loop);
204 to print each warning only only the first time it occurs in each
207 to print each warning only the first time it occurs in the program; or
209 to raise an exception instead of printing a warning message.
214 .IB action : message : category : module : line.
217 is as explained above but only applies to messages that match the
218 remaining fields. Empty fields match all values; trailing empty
219 fields may be omitted. The
221 field matches the start of the warning message printed; this match is
222 case-insensitive. The
224 field matches the warning category. This must be a class name; the
225 match test whether the actual warning category of the message is a
226 subclass of the specified warning category. The full class name must
229 field matches the (fully-qualified) module name; this match is
232 field matches the line number, where zero matches all line numbers and
233 is thus equivalent to an omitted line number.
236 Skip the first line of the source. This is intended for a DOS
237 specific hack only. Warning: the line numbers in error messages will
239 .SH INTERPRETER INTERFACE
240 The interpreter interface resembles that of the UNIX shell: when
241 called with standard input connected to a tty device, it prompts for
242 commands and executes them until an EOF is read; when called with a
243 file name argument or with a file as standard input, it reads and
250 it executes the Python statement(s) given as
254 may contain multiple statements separated by newlines.
255 Leading whitespace is significant in Python statements!
256 In non-interactive mode, the entire input is parsed before it is
259 If available, the script name and additional arguments thereafter are
260 passed to the script in the Python variable
262 which is a list of strings (you must first
264 to be able to access it).
265 If no script name is given,
267 is an empty string; if
273 Note that options interpreted by the Python interpreter itself
277 In interactive mode, the primary prompt is `>>>'; the second prompt
278 (which appears when a command is not complete) is `...'.
279 The prompts can be changed by assignment to
283 The interpreter quits when it reads an EOF at a prompt.
284 When an unhandled exception occurs, a stack trace is printed and
285 control returns to the primary prompt; in non-interactive mode, the
286 interpreter exits after printing the stack trace.
287 The interrupt signal raises the
288 .I Keyboard\%Interrupt
289 exception; other UNIX signals are not caught (except that SIGPIPE is
290 sometimes ignored, in favor of the
292 exception). Error messages are written to stderr.
293 .SH FILES AND DIRECTORIES
294 These are subject to difference depending on local installation
295 conventions; ${prefix} and ${exec_prefix} are installation-dependent
296 and should be interpreted as for GNU software; they may be the same.
297 The default for both is \fI/usr/local\fP.
298 .IP \fI${exec_prefix}/bin/python\fP
299 Recommended location of the interpreter.
301 .I ${prefix}/lib/python<version>
303 .I ${exec_prefix}/lib/python<version>
305 Recommended locations of the directories containing the standard
309 .I ${prefix}/include/python<version>
311 .I ${exec_prefix}/include/python<version>
313 Recommended locations of the directories containing the include files
314 needed for developing Python extensions and embedding the
317 .IP \fI~/.pythonrc.py\fP
318 User-specific initialization file loaded by the \fIuser\fP module;
319 not used by default or by most applications.
320 .SH ENVIRONMENT VARIABLES
322 Change the location of the standard Python libraries. By default, the
323 libraries are searched in ${prefix}/lib/python<version> and
324 ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
325 are installation-dependent directories, both defaulting to
326 \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
327 replaces both ${prefix} and ${exec_prefix}. To specify different values
328 for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
330 Augments the default search path for module files.
331 The format is the same as the shell's $PATH: one or more directory
332 pathnames separated by colons.
333 Non-existent directories are silently ignored.
334 The default search path is installation dependent, but generally
335 begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
336 The default search path is always appended to $PYTHONPATH.
337 If a script argument is given, the directory containing the script is
338 inserted in the path in front of $PYTHONPATH.
339 The search path can be manipulated from within a Python program as the
343 If this is the name of a readable file, the Python commands in that
344 file are executed before the first prompt is displayed in interactive
346 The file is executed in the same name space where interactive commands
347 are executed so that objects defined or imported in it can be used
348 without qualification in the interactive session.
349 You can also change the prompts
355 Set this to a non-empty string to cause the \fItime\fP module to
356 require dates specified as strings to include 4-digit years, otherwise
357 2-digit years are converted based on rules described in the \fItime\fP
358 module documentation.
360 If this is set to a non-empty string it is equivalent to specifying
361 the \fB\-O\fP option. If set to an integer, it is equivalent to
362 specifying \fB\-O\fP multiple times.
364 If this is set to a non-empty string it is equivalent to specifying
365 the \fB\-d\fP option. If set to an integer, it is equivalent to
366 specifying \fB\-d\fP multiple times.
368 If this is set to a non-empty string it is equivalent to specifying
369 the \fB\-i\fP option.
371 If this is set to a non-empty string it is equivalent to specifying
372 the \fB\-u\fP option.
374 If this is set to a non-empty string it is equivalent to specifying
375 the \fB\-v\fP option. If set to an integer, it is equivalent to
376 specifying \fB\-v\fP multiple times.
378 The Python Software Foundation: http://www.python.org/psf
379 .SH INTERNET RESOURCES
380 Main website: http://www.python.org/
382 Documentation: http://docs.python.org/
384 Community website: http://starship.python.net/
386 Developer resources: http://www.python.org/dev/
388 FTP: ftp://ftp.python.org/pub/python/
390 Module repository: http://www.vex.net/parnassus/
392 Newsgroups: comp.lang.python, comp.lang.python.announce
394 Python is distributed under an Open Source license. See the file
395 "LICENSE" in the Python source distribution for information on terms &
396 conditions for accessing and otherwise using Python and for a
397 DISCLAIMER OF ALL WARRANTIES.