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