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
85 Python is an interpreted, interactive, object-oriented programming
86 language that combines remarkable power with very clear syntax.
87 For an introduction to programming in Python you are referred to the
89 The Python Library Reference documents built-in and standard types,
90 constants, functions and modules.
91 Finally, the Python Reference Manual describes the syntax and
92 semantics of the core language in (perhaps too) much detail.
93 (These documents may be located via the
94 .B "INTERNET RESOURCES"
95 below; they may be installed on your system as well.)
97 Python's basic power can be extended with your own modules written in
99 On most systems such modules may be dynamically loaded.
100 Python is also adaptable as an extension language for existing
102 See the internal documentation for hints.
104 Documentation for installed Python modules and packages can be
105 viewed by running the
108 .SH COMMAND LINE OPTIONS
113 files on import. See also PYTHONDONTWRITEBYTECODE.
116 Specify the command to execute (see next section).
117 This terminates the option list (following options are passed as
118 arguments to the command).
121 Turn on parser debugging output (for wizards only, depending on
122 compilation options).
125 Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
126 the behavior of the interpreter.
128 .B \-h ", " \-? ", "\-\-help
129 Prints the usage for the interpreter executable and exits.
132 When a script is passed as first argument or the \fB\-c\fP option is
133 used, enter interactive mode after executing the script or the
134 command. It does not read the $PYTHONSTARTUP file. This can be
135 useful to inspect global variables or a stack trace when a script
138 .BI "\-m " module-name
141 for the named module and runs the corresponding
146 Turn on basic optimizations. This changes the filename extension for
147 compiled (bytecode) files from
149 to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
152 Discard docstrings in addition to the \fB-O\fP optimizations.
155 Division control; see PEP 238. The argument must be one of "old" (the
156 default, int/int and long/long return an int or long), "new" (new
157 division semantics, i.e. int/int and long/long returns a float),
158 "warn" (old division semantics with a warning for int/int and
159 long/long), or "warnall" (old division semantics with a warning for
160 all use of the division operator). For a use of "warnall", see the
161 Tools/scripts/fixdiv.py script.
164 Don't add user site directory to sys.path.
167 Disable the import of the module
169 and the site-dependent manipulations of
174 Issue a warning when a source file mixes tabs and spaces for
175 indentation in a way that makes it depend on the worth of a tab
176 expressed in spaces. Issue an error when the option is given twice.
179 Force stdin, stdout and stderr to be totally unbuffered. On systems
180 where it matters, also put stdin, stdout and stderr in binary mode.
181 Note that there is internal buffering in xreadlines(), readlines() and
182 file-object iterators ("for line in sys.stdin") which is not
183 influenced by this option. To work around this, you will want to use
184 "sys.stdin.readline()" inside a "while 1:" loop.
187 Print a message each time a module is initialized, showing the place
188 (filename or built-in module) from which it is loaded. When given
189 twice, print a message for each file that is checked for when
190 searching for a module. Also provides information on module cleanup
193 .B \-V ", " \-\-version
194 Prints the Python version number of the executable and exits.
197 Warning control. Python sometimes prints warning message to
199 A typical warning message has the following form:
200 .IB file ":" line ": " category ": " message.
201 By default, each warning is printed once for each source line where it
202 occurs. This option controls how often warnings are printed.
205 options may be given; when a warning matches more than one
206 option, the action for the last matching option is performed.
209 options are ignored (a warning message is printed about invalid
210 options when the first warning is issued). Warnings can also be
211 controlled from within a Python program using the
217 is one of the following
219 strings (or a unique abbreviation):
221 to ignore all warnings;
223 to explicitly request the default behavior (printing each warning once
226 to print a warning each time it occurs (this may generate many
227 messages if a warning is triggered repeatedly for the same source
228 line, such as inside a loop);
230 to print each warning only the first time it occurs in each
233 to print each warning only the first time it occurs in the program; or
235 to raise an exception instead of printing a warning message.
240 .IB action : message : category : module : line.
243 is as explained above but only applies to messages that match the
244 remaining fields. Empty fields match all values; trailing empty
245 fields may be omitted. The
247 field matches the start of the warning message printed; this match is
248 case-insensitive. The
250 field matches the warning category. This must be a class name; the
251 match test whether the actual warning category of the message is a
252 subclass of the specified warning category. The full class name must
255 field matches the (fully-qualified) module name; this match is
258 field matches the line number, where zero matches all line numbers and
259 is thus equivalent to an omitted line number.
262 Skip the first line of the source. This is intended for a DOS
263 specific hack only. Warning: the line numbers in error messages will
267 Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix.
268 .SH INTERPRETER INTERFACE
269 The interpreter interface resembles that of the UNIX shell: when
270 called with standard input connected to a tty device, it prompts for
271 commands and executes them until an EOF is read; when called with a
272 file name argument or with a file as standard input, it reads and
279 it executes the Python statement(s) given as
283 may contain multiple statements separated by newlines.
284 Leading whitespace is significant in Python statements!
285 In non-interactive mode, the entire input is parsed before it is
288 If available, the script name and additional arguments thereafter are
289 passed to the script in the Python variable
291 which is a list of strings (you must first
293 to be able to access it).
294 If no script name is given,
296 is an empty string; if
302 Note that options interpreted by the Python interpreter itself
306 In interactive mode, the primary prompt is `>>>'; the second prompt
307 (which appears when a command is not complete) is `...'.
308 The prompts can be changed by assignment to
312 The interpreter quits when it reads an EOF at a prompt.
313 When an unhandled exception occurs, a stack trace is printed and
314 control returns to the primary prompt; in non-interactive mode, the
315 interpreter exits after printing the stack trace.
316 The interrupt signal raises the
317 .I Keyboard\%Interrupt
318 exception; other UNIX signals are not caught (except that SIGPIPE is
319 sometimes ignored, in favor of the
321 exception). Error messages are written to stderr.
322 .SH FILES AND DIRECTORIES
323 These are subject to difference depending on local installation
324 conventions; ${prefix} and ${exec_prefix} are installation-dependent
325 and should be interpreted as for GNU software; they may be the same.
326 The default for both is \fI/usr/local\fP.
327 .IP \fI${exec_prefix}/bin/python\fP
328 Recommended location of the interpreter.
330 .I ${prefix}/lib/python<version>
332 .I ${exec_prefix}/lib/python<version>
334 Recommended locations of the directories containing the standard
338 .I ${prefix}/include/python<version>
340 .I ${exec_prefix}/include/python<version>
342 Recommended locations of the directories containing the include files
343 needed for developing Python extensions and embedding the
346 .IP \fI~/.pythonrc.py\fP
347 User-specific initialization file loaded by the \fIuser\fP module;
348 not used by default or by most applications.
349 .SH ENVIRONMENT VARIABLES
351 Change the location of the standard Python libraries. By default, the
352 libraries are searched in ${prefix}/lib/python<version> and
353 ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
354 are installation-dependent directories, both defaulting to
355 \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
356 replaces both ${prefix} and ${exec_prefix}. To specify different values
357 for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
359 Augments the default search path for module files.
360 The format is the same as the shell's $PATH: one or more directory
361 pathnames separated by colons.
362 Non-existent directories are silently ignored.
363 The default search path is installation dependent, but generally
364 begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
365 The default search path is always appended to $PYTHONPATH.
366 If a script argument is given, the directory containing the script is
367 inserted in the path in front of $PYTHONPATH.
368 The search path can be manipulated from within a Python program as the
372 If this is the name of a readable file, the Python commands in that
373 file are executed before the first prompt is displayed in interactive
375 The file is executed in the same name space where interactive commands
376 are executed so that objects defined or imported in it can be used
377 without qualification in the interactive session.
378 You can also change the prompts
384 Set this to a non-empty string to cause the \fItime\fP module to
385 require dates specified as strings to include 4-digit years, otherwise
386 2-digit years are converted based on rules described in the \fItime\fP
387 module documentation.
389 If this is set to a non-empty string it is equivalent to specifying
390 the \fB\-O\fP option. If set to an integer, it is equivalent to
391 specifying \fB\-O\fP multiple times.
393 If this is set to a non-empty string it is equivalent to specifying
394 the \fB\-d\fP option. If set to an integer, it is equivalent to
395 specifying \fB\-d\fP multiple times.
396 .IP PYTHONDONTWRITEBYTECODE
397 If this is set to a non-empty string it is equivalent to specifying
398 the \fB\-B\fP option (don't try to write
402 If this is set to a non-empty string it is equivalent to specifying
403 the \fB\-i\fP option.
405 If this is set to a non-empty string it is equivalent to specifying
406 the \fB\-s\fP option (Don't add the user site directory to sys.path).
408 If this is set to a non-empty string it is equivalent to specifying
409 the \fB\-u\fP option.
411 If this is set to a non-empty string it is equivalent to specifying
412 the \fB\-v\fP option. If set to an integer, it is equivalent to
413 specifying \fB\-v\fP multiple times.
415 If this is set to a comma-separated string it is equivalent to
416 specifying the \fB\-W\fP option for each separate value.
418 The Python Software Foundation: http://www.python.org/psf
419 .SH INTERNET RESOURCES
420 Main website: http://www.python.org/
422 Documentation: http://docs.python.org/
424 Developer resources: http://www.python.org/dev/
426 Downloads: http://python.org/download/
428 Module repository: http://pypi.python.org/
430 Newsgroups: comp.lang.python, comp.lang.python.announce
432 Python is distributed under an Open Source license. See the file
433 "LICENSE" in the Python source distribution for information on terms &
434 conditions for accessing and otherwise using Python and for a
435 DISCLAIMER OF ALL WARRANTIES.