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