source: python/vendor/Python-2.6.5/Misc/python.man

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 12.6 KB
Line 
1.TH PYTHON "1" "$Date: 2010-01-31 11:09:16 -0500 (Sun, 31 Jan 2010) $"
2
3.\" To view this file while editing, run it through groff:
4.\" groff -Tascii -man python.man | less
5
6.SH NAME
7python \- an interpreted, interactive, object-oriented programming language
8.SH SYNOPSIS
9.B python
10[
11.B \-B
12]
13[
14.B \-d
15]
16[
17.B \-E
18]
19[
20.B \-h
21]
22[
23.B \-i
24]
25[
26.B \-m
27.I module-name
28]
29.br
30 [
31.B \-O
32]
33[
34.B \-O0
35]
36[
37.B -Q
38.I argument
39]
40[
41.B \-s
42]
43[
44.B \-S
45]
46[
47.B \-t
48]
49[
50.B \-u
51]
52.br
53 [
54.B \-v
55]
56[
57.B \-V
58]
59[
60.B \-W
61.I argument
62]
63[
64.B \-x
65]
66[
67.B \-3
68]
69[
70.B \-?
71]
72.br
73 [
74.B \-c
75.I command
76|
77.I script
78|
79\-
80]
81[
82.I arguments
83]
84.SH DESCRIPTION
85Python is an interpreted, interactive, object-oriented programming
86language that combines remarkable power with very clear syntax.
87For an introduction to programming in Python you are referred to the
88Python Tutorial.
89The Python Library Reference documents built-in and standard types,
90constants, functions and modules.
91Finally, the Python Reference Manual describes the syntax and
92semantics of the core language in (perhaps too) much detail.
93(These documents may be located via the
94.B "INTERNET RESOURCES"
95below; they may be installed on your system as well.)
96.PP
97Python's basic power can be extended with your own modules written in
98C or C++.
99On most systems such modules may be dynamically loaded.
100Python is also adaptable as an extension language for existing
101applications.
102See the internal documentation for hints.
103.PP
104Documentation for installed Python modules and packages can be
105viewed by running the
106.B pydoc
107program.
108.SH COMMAND LINE OPTIONS
109.TP
110.B \-B
111Don't write
112.I .py[co]
113files on import. See also PYTHONDONTWRITEBYTECODE.
114.TP
115.BI "\-c " command
116Specify the command to execute (see next section).
117This terminates the option list (following options are passed as
118arguments to the command).
119.TP
120.B \-d
121Turn on parser debugging output (for wizards only, depending on
122compilation options).
123.TP
124.B \-E
125Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
126the behavior of the interpreter.
127.TP
128.B \-h ", " \-? ", "\-\-help
129Prints the usage for the interpreter executable and exits.
130.TP
131.B \-i
132When a script is passed as first argument or the \fB\-c\fP option is
133used, enter interactive mode after executing the script or the
134command. It does not read the $PYTHONSTARTUP file. This can be
135useful to inspect global variables or a stack trace when a script
136raises an exception.
137.TP
138.BI "\-m " module-name
139Searches
140.I sys.path
141for the named module and runs the corresponding
142.I .py
143file as a script.
144.TP
145.B \-O
146Turn on basic optimizations. This changes the filename extension for
147compiled (bytecode) files from
148.I .pyc
149to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
150.TP
151.B \-O0
152Discard docstrings in addition to the \fB-O\fP optimizations.
153.TP
154.BI "\-Q " argument
155Division control; see PEP 238. The argument must be one of "old" (the
156default, int/int and long/long return an int or long), "new" (new
157division semantics, i.e. int/int and long/long returns a float),
158"warn" (old division semantics with a warning for int/int and
159long/long), or "warnall" (old division semantics with a warning for
160all use of the division operator). For a use of "warnall", see the
161Tools/scripts/fixdiv.py script.
162.TP
163.B \-s
164Don't add user site directory to sys.path.
165.TP
166.B \-S
167Disable the import of the module
168.I site
169and the site-dependent manipulations of
170.I sys.path
171that it entails.
172.TP
173.B \-t
174Issue a warning when a source file mixes tabs and spaces for
175indentation in a way that makes it depend on the worth of a tab
176expressed in spaces. Issue an error when the option is given twice.
177.TP
178.B \-u
179Force stdin, stdout and stderr to be totally unbuffered. On systems
180where it matters, also put stdin, stdout and stderr in binary mode.
181Note that there is internal buffering in xreadlines(), readlines() and
182file-object iterators ("for line in sys.stdin") which is not
183influenced by this option. To work around this, you will want to use
184"sys.stdin.readline()" inside a "while 1:" loop.
185.TP
186.B \-v
187Print a message each time a module is initialized, showing the place
188(filename or built-in module) from which it is loaded. When given
189twice, print a message for each file that is checked for when
190searching for a module. Also provides information on module cleanup
191at exit.
192.TP
193.B \-V ", " \-\-version
194Prints the Python version number of the executable and exits.
195.TP
196.BI "\-W " argument
197Warning control. Python sometimes prints warning message to
198.IR sys.stderr .
199A typical warning message has the following form:
200.IB file ":" line ": " category ": " message.
201By default, each warning is printed once for each source line where it
202occurs. This option controls how often warnings are printed.
203Multiple
204.B \-W
205options may be given; when a warning matches more than one
206option, the action for the last matching option is performed.
207Invalid
208.B \-W
209options are ignored (a warning message is printed about invalid
210options when the first warning is issued). Warnings can also be
211controlled from within a Python program using the
212.I warnings
213module.
214
215The simplest form of
216.I argument
217is one of the following
218.I action
219strings (or a unique abbreviation):
220.B ignore
221to ignore all warnings;
222.B default
223to explicitly request the default behavior (printing each warning once
224per source line);
225.B all
226to print a warning each time it occurs (this may generate many
227messages if a warning is triggered repeatedly for the same source
228line, such as inside a loop);
229.B module
230to print each warning only the first time it occurs in each
231module;
232.B once
233to print each warning only the first time it occurs in the program; or
234.B error
235to raise an exception instead of printing a warning message.
236
237The full form of
238.I argument
239is
240.IB action : message : category : module : line.
241Here,
242.I action
243is as explained above but only applies to messages that match the
244remaining fields. Empty fields match all values; trailing empty
245fields may be omitted. The
246.I message
247field matches the start of the warning message printed; this match is
248case-insensitive. The
249.I category
250field matches the warning category. This must be a class name; the
251match test whether the actual warning category of the message is a
252subclass of the specified warning category. The full class name must
253be given. The
254.I module
255field matches the (fully-qualified) module name; this match is
256case-sensitive. The
257.I line
258field matches the line number, where zero matches all line numbers and
259is thus equivalent to an omitted line number.
260.TP
261.B \-x
262Skip the first line of the source. This is intended for a DOS
263specific hack only. Warning: the line numbers in error messages will
264be off by one!
265.TP
266.B \-3
267Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix.
268.SH INTERPRETER INTERFACE
269The interpreter interface resembles that of the UNIX shell: when
270called with standard input connected to a tty device, it prompts for
271commands and executes them until an EOF is read; when called with a
272file name argument or with a file as standard input, it reads and
273executes a
274.I script
275from that file;
276when called with
277.B \-c
278.I command,
279it executes the Python statement(s) given as
280.I command.
281Here
282.I command
283may contain multiple statements separated by newlines.
284Leading whitespace is significant in Python statements!
285In non-interactive mode, the entire input is parsed before it is
286executed.
287.PP
288If available, the script name and additional arguments thereafter are
289passed to the script in the Python variable
290.I sys.argv ,
291which is a list of strings (you must first
292.I import sys
293to be able to access it).
294If no script name is given,
295.I sys.argv[0]
296is an empty string; if
297.B \-c
298is used,
299.I sys.argv[0]
300contains the string
301.I '-c'.
302Note that options interpreted by the Python interpreter itself
303are not placed in
304.I sys.argv.
305.PP
306In interactive mode, the primary prompt is `>>>'; the second prompt
307(which appears when a command is not complete) is `...'.
308The prompts can be changed by assignment to
309.I sys.ps1
310or
311.I sys.ps2.
312The interpreter quits when it reads an EOF at a prompt.
313When an unhandled exception occurs, a stack trace is printed and
314control returns to the primary prompt; in non-interactive mode, the
315interpreter exits after printing the stack trace.
316The interrupt signal raises the
317.I Keyboard\%Interrupt
318exception; other UNIX signals are not caught (except that SIGPIPE is
319sometimes ignored, in favor of the
320.I IOError
321exception). Error messages are written to stderr.
322.SH FILES AND DIRECTORIES
323These are subject to difference depending on local installation
324conventions; ${prefix} and ${exec_prefix} are installation-dependent
325and should be interpreted as for GNU software; they may be the same.
326The default for both is \fI/usr/local\fP.
327.IP \fI${exec_prefix}/bin/python\fP
328Recommended location of the interpreter.
329.PP
330.I ${prefix}/lib/python<version>
331.br
332.I ${exec_prefix}/lib/python<version>
333.RS
334Recommended locations of the directories containing the standard
335modules.
336.RE
337.PP
338.I ${prefix}/include/python<version>
339.br
340.I ${exec_prefix}/include/python<version>
341.RS
342Recommended locations of the directories containing the include files
343needed for developing Python extensions and embedding the
344interpreter.
345.RE
346.IP \fI~/.pythonrc.py\fP
347User-specific initialization file loaded by the \fIuser\fP module;
348not used by default or by most applications.
349.SH ENVIRONMENT VARIABLES
350.IP PYTHONHOME
351Change the location of the standard Python libraries. By default, the
352libraries are searched in ${prefix}/lib/python<version> and
353${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
354are installation-dependent directories, both defaulting to
355\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
356replaces both ${prefix} and ${exec_prefix}. To specify different values
357for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
358.IP PYTHONPATH
359Augments the default search path for module files.
360The format is the same as the shell's $PATH: one or more directory
361pathnames separated by colons.
362Non-existent directories are silently ignored.
363The default search path is installation dependent, but generally
364begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
365The default search path is always appended to $PYTHONPATH.
366If a script argument is given, the directory containing the script is
367inserted in the path in front of $PYTHONPATH.
368The search path can be manipulated from within a Python program as the
369variable
370.I sys.path .
371.IP PYTHONSTARTUP
372If this is the name of a readable file, the Python commands in that
373file are executed before the first prompt is displayed in interactive
374mode.
375The file is executed in the same name space where interactive commands
376are executed so that objects defined or imported in it can be used
377without qualification in the interactive session.
378You can also change the prompts
379.I sys.ps1
380and
381.I sys.ps2
382in this file.
383.IP PYTHONY2K
384Set this to a non-empty string to cause the \fItime\fP module to
385require dates specified as strings to include 4-digit years, otherwise
3862-digit years are converted based on rules described in the \fItime\fP
387module documentation.
388.IP PYTHONOPTIMIZE
389If this is set to a non-empty string it is equivalent to specifying
390the \fB\-O\fP option. If set to an integer, it is equivalent to
391specifying \fB\-O\fP multiple times.
392.IP PYTHONDEBUG
393If this is set to a non-empty string it is equivalent to specifying
394the \fB\-d\fP option. If set to an integer, it is equivalent to
395specifying \fB\-d\fP multiple times.
396.IP PYTHONDONTWRITEBYTECODE
397If this is set to a non-empty string it is equivalent to specifying
398the \fB\-B\fP option (don't try to write
399.I .py[co]
400files).
401.IP PYTHONINSPECT
402If this is set to a non-empty string it is equivalent to specifying
403the \fB\-i\fP option.
404.IP PYTHONNOUSERSITE
405If this is set to a non-empty string it is equivalent to specifying
406the \fB\-s\fP option (Don't add the user site directory to sys.path).
407.IP PYTHONUNBUFFERED
408If this is set to a non-empty string it is equivalent to specifying
409the \fB\-u\fP option.
410.IP PYTHONVERBOSE
411If this is set to a non-empty string it is equivalent to specifying
412the \fB\-v\fP option. If set to an integer, it is equivalent to
413specifying \fB\-v\fP multiple times.
414.SH AUTHOR
415The Python Software Foundation: http://www.python.org/psf
416.SH INTERNET RESOURCES
417Main website: http://www.python.org/
418.br
419Documentation: http://docs.python.org/
420.br
421Developer resources: http://www.python.org/dev/
422.br
423Downloads: http://python.org/download/
424.br
425Module repository: http://pypi.python.org/
426.br
427Newsgroups: comp.lang.python, comp.lang.python.announce
428.SH LICENSING
429Python is distributed under an Open Source license. See the file
430"LICENSE" in the Python source distribution for information on terms &
431conditions for accessing and otherwise using Python and for a
432DISCLAIMER OF ALL WARRANTIES.
Note: See TracBrowser for help on using the repository browser.