Fred Drake | f2e9e29 | 1999-08-20 13:30:49 +0000 | [diff] [blame] | 1 | .TH PYTHON "1" "20 August, 1999" |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 2 | .SH NAME |
| 3 | python \- an interpreted, interactive, object-oriented programming language |
| 4 | .SH SYNOPSIS |
| 5 | .B python |
| 6 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 7 | .B \-d |
| 8 | ] |
| 9 | [ |
| 10 | .B \-i |
| 11 | ] |
| 12 | [ |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 13 | .B \-O |
| 14 | ] |
| 15 | [ |
| 16 | .B \-S |
| 17 | ] |
| 18 | [ |
Guido van Rossum | 29d465b | 1998-04-10 19:36:09 +0000 | [diff] [blame] | 19 | .B \-t |
| 20 | ] |
| 21 | [ |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 22 | .B \-u |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 23 | ] |
| 24 | [ |
| 25 | .B \-v |
| 26 | ] |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 27 | .br |
| 28 | [ |
Guido van Rossum | 07c44c7 | 1998-04-10 19:46:00 +0000 | [diff] [blame] | 29 | .B \-x |
| 30 | ] |
| 31 | [ |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 32 | .B \-X |
| 33 | ] |
| 34 | .br |
| 35 | [ |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 36 | .B \-c |
| 37 | .I command |
| 38 | | |
| 39 | .I script |
| 40 | | |
| 41 | \- |
| 42 | ] |
| 43 | [ |
| 44 | .I arguments |
| 45 | ] |
| 46 | .SH DESCRIPTION |
| 47 | Python is an interpreted, interactive, object-oriented programming |
| 48 | language that combines remarkable power with very clear syntax. |
| 49 | For an introduction to programming in Python you are referred to the |
| 50 | Python Tutorial. |
| 51 | The Python Library Reference documents built-in and standard types, |
| 52 | constants, functions and modules. |
| 53 | Finally, the Python Reference Manual describes the syntax and |
| 54 | semantics of the core language in (perhaps too) much detail. |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 55 | (Information on locating these documents is included in |
| 56 | .B "SEE ALSO" |
| 57 | below; they may be installed on your system as well.) |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 58 | .PP |
| 59 | Python's basic power can be extended with your own modules written in |
| 60 | C or C++. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 61 | On most systems such modules may be dynamically loaded. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 62 | Python is also adaptable as an extension language for existing |
| 63 | applications. |
| 64 | See the internal documentation for hints. |
| 65 | .SH COMMAND LINE OPTIONS |
| 66 | .TP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 67 | .B \-d |
| 68 | Turn on parser debugging output (for wizards only, depending on |
| 69 | compilation options). |
Guido van Rossum | 9f65ae0 | 1994-02-23 09:10:27 +0000 | [diff] [blame] | 70 | .TP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 71 | .B \-i |
| 72 | When a script is passed as first argument or the \fB\-c\fP option is |
| 73 | used, enter interactive mode after executing the script or the |
Guido van Rossum | 9f65ae0 | 1994-02-23 09:10:27 +0000 | [diff] [blame] | 74 | command. It does not read the $PYTHONSTARTUP file. This can be |
| 75 | useful to inspect global variables or a stack trace when a script |
| 76 | raises an exception. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 77 | .TP |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 78 | .B \-O |
| 79 | Turn on basic optimizations. This changes the filename extension for |
| 80 | compiled (bytecode) files from |
| 81 | .I .pyc |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 82 | to \fI.pyo\fP. Given twice, causes docstrings to be discarded. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 83 | .TP |
| 84 | .B \-S |
| 85 | Disable the import of the module |
| 86 | .I site |
| 87 | and the site-dependent manipulations of |
| 88 | .I sys.path |
| 89 | that it entails. |
| 90 | .TP |
Guido van Rossum | 29d465b | 1998-04-10 19:36:09 +0000 | [diff] [blame] | 91 | .B \-t |
| 92 | Issue a warning when a source file mixes tabs and spaces for |
| 93 | indentation in a way that makes it depend on the worth of a tab |
| 94 | expressed in spaces. Issue an error when the option is given twice. |
| 95 | .TP |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 96 | .B \-u |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 97 | Force stdin, stdout and stderr to be totally unbuffered. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 98 | .TP |
| 99 | .B \-v |
| 100 | Print a message each time a module is initialized, showing the place |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 101 | (filename or built-in module) from which it is loaded. When given |
| 102 | twice, print a message for each file that is checked for when |
| 103 | searching for a module. Also provides information on module cleanup |
| 104 | at exit. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 105 | .TP |
Guido van Rossum | 07c44c7 | 1998-04-10 19:46:00 +0000 | [diff] [blame] | 106 | .B \-x |
| 107 | Skip the first line of the source. This is intended for a DOS |
| 108 | specific hack only. Warning: the line numbers in error messages will |
| 109 | be off by one! |
| 110 | .TP |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 111 | .B \-X |
| 112 | Make the standard exceptions strings instead of classes. |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 113 | Use for backward compatibility with old code only. This is not |
| 114 | necessary for most uses of string exceptions. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 115 | .TP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 116 | .BI "\-c " command |
| 117 | Specify the command to execute (see next section). |
| 118 | This terminates the option list (following options are passed as |
| 119 | arguments to the command). |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 120 | .SH INTERPRETER INTERFACE |
| 121 | The interpreter interface resembles that of the UNIX shell: when |
| 122 | called with standard input connected to a tty device, it prompts for |
| 123 | commands and executes them until an EOF is read; when called with a |
| 124 | file name argument or with a file as standard input, it reads and |
| 125 | executes a |
| 126 | .I script |
| 127 | from that file; |
| 128 | when called with |
| 129 | .B \-c |
| 130 | .I command, |
| 131 | it executes the Python statement(s) given as |
| 132 | .I command. |
| 133 | Here |
| 134 | .I command |
| 135 | may contain multiple statements separated by newlines. |
| 136 | Leading whitespace is significant in Python statements! |
| 137 | In non-interactive mode, the entire input is parsed befored it is |
| 138 | executed. |
| 139 | .PP |
| 140 | If available, the script name and additional arguments thereafter are |
| 141 | passed to the script in the Python variable |
| 142 | .I sys.argv , |
| 143 | which is a list of strings (you must first |
| 144 | .I import sys |
| 145 | to be able to access it). |
| 146 | If no script name is given, |
| 147 | .I sys.argv |
| 148 | is empty; if |
| 149 | .B \-c |
| 150 | is used, |
| 151 | .I sys.argv[0] |
| 152 | contains the string |
| 153 | .I '-c'. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 154 | Note that options interpreted by the Python interpreter itself |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 155 | are not placed in |
| 156 | .I sys.argv. |
| 157 | .PP |
| 158 | In interactive mode, the primary prompt is `>>>'; the second prompt |
| 159 | (which appears when a command is not complete) is `...'. |
| 160 | The prompts can be changed by assignment to |
| 161 | .I sys.ps1 |
| 162 | or |
| 163 | .I sys.ps2. |
| 164 | The interpreter quits when it reads an EOF at a prompt. |
| 165 | When an unhandled exception occurs, a stack trace is printed and |
| 166 | control returns to the primary prompt; in non-interactive mode, the |
| 167 | interpreter exits after printing the stack trace. |
| 168 | The interrupt signal raises the |
| 169 | .I Keyboard\%Interrupt |
| 170 | exception; other UNIX signals are not caught (except that SIGPIPE is |
| 171 | sometimes ignored, in favor of the |
| 172 | .I IOError |
| 173 | exception). Error messages are written to stderr. |
| 174 | .SH FILES AND DIRECTORIES |
| 175 | These are subject to difference depending on local installation |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 176 | conventions; ${prefix} and ${exec_prefix} are installation-dependent |
| 177 | and should be interpreted as for GNU software; they may be the same. |
| 178 | The default for both is \fI/usr/local\fP. |
| 179 | .IP \fI${exec_prefix}/bin/python\fP |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 180 | Recommended location of the interpreter. |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 181 | .PP |
| 182 | .I ${prefix}/lib/python<version> |
| 183 | .br |
| 184 | .I ${exec_prefix}/lib/python<version> |
| 185 | .RS |
| 186 | Recommended locations of the directories containing the standard |
| 187 | modules. |
| 188 | .RE |
| 189 | .PP |
| 190 | .I ${prefix}/include/python<version> |
| 191 | .br |
| 192 | .I ${exec_prefix}/include/python<version> |
| 193 | .RS |
| 194 | Recommended locations of the directories containing the include files |
| 195 | needed for developing Python extensions and embedding the |
| 196 | interpreter. |
| 197 | .RE |
| 198 | .IP \fI~/.pythonrc.py\fP |
| 199 | User-specific initialization file loaded by the \fIuser\fP module; |
| 200 | not used by default or by most applications. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 201 | .SH ENVIRONMENT VARIABLES |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 202 | .IP PYTHONHOME |
| 203 | Change the location of the standard Python libraries. By default, the |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 204 | libraries are searched in ${prefix}/lib/python<version> and |
| 205 | ${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix} |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 206 | are installation-dependent directories, both defaulting to |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 207 | \fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value |
| 208 | replaces both ${prefix} and ${exec_prefix}. To specify different values |
| 209 | for these, set $PYTHONHOME to ${prefix}:${exec_prefix}. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 210 | .IP PYTHONPATH |
| 211 | Augments the default search path for module files. |
| 212 | The format is the same as the shell's $PATH: one or more directory |
| 213 | pathnames separated by colons. |
| 214 | Non-existant directories are silently ignored. |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 215 | The default search path is installation dependent, but generally |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 216 | begins with ${prefix}/lib/python<version> (see PYTHONHOME above). |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 217 | The default search path is always appended to $PYTHONPATH. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 218 | If a script argument is given, the directory containing the script is |
| 219 | inserted in the path in front of $PYTHONPATH. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 220 | The search path can be manipulated from within a Python program as the |
| 221 | variable |
| 222 | .I sys.path . |
| 223 | .IP PYTHONSTARTUP |
| 224 | If this is the name of a readable file, the Python commands in that |
| 225 | file are executed before the first prompt is displayed in interactive |
| 226 | mode. |
| 227 | The file is executed in the same name space where interactive commands |
| 228 | are executed so that objects defined or imported in it can be used |
| 229 | without qualification in the interactive session. |
| 230 | You can also change the prompts |
| 231 | .I sys.ps1 |
| 232 | and |
| 233 | .I sys.ps2 |
| 234 | in this file. |
| 235 | .IP PYTHONDEBUG |
| 236 | If this is set to a non-empty string it is equivalent to specifying |
| 237 | the \fB\-d\fP option. |
| 238 | .IP PYTHONINSPECT |
| 239 | If this is set to a non-empty string it is equivalent to specifying |
| 240 | the \fB\-i\fP option. |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 241 | .IP PYTHONUNBUFFERED |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 242 | If this is set to a non-empty string it is equivalent to specifying |
Guido van Rossum | ef5bca3 | 1994-05-03 14:15:32 +0000 | [diff] [blame] | 243 | the \fB\-u\fP option. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 244 | .IP PYTHONVERBOSE |
| 245 | If this is set to a non-empty string it is equivalent to specifying |
| 246 | the \fB\-v\fP option. |
| 247 | .SH SEE ALSO |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 248 | .IP "Python Tutorial" |
| 249 | URL: http://www.python.org/doc/tut/tut.html |
| 250 | .IP "Python Library Reference" |
| 251 | URL: http://www.python.org/doc/lib/lib.html |
| 252 | .IP "Python Reference Manual" |
| 253 | URL: http://www.python.org/doc/ref/ref.html |
| 254 | .IP "Extending and Embedding the Python Interpreter" |
| 255 | URL: http://www.python.org/doc/ext/ext.html |
| 256 | .IP "Python/C API" |
| 257 | URL: http://www.python.org/doc/api/api.html |
| 258 | .PP |
| 259 | Downloadable versions of these documents in many formats are available |
| 260 | at the Python website; see \fB\INTERNET RESOURCES\fP below. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 261 | .SH AUTHOR |
| 262 | .nf |
| 263 | Guido van Rossum |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 264 | CNRI |
| 265 | 1895 Preston White Drive |
| 266 | Reston, VA 20191 |
| 267 | USA |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 268 | .PP |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 269 | E-mail: guido@cnri.reston.va.us, guido@python.org |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 270 | .fi |
Guido van Rossum | 4cf4de5 | 1997-09-08 04:06:15 +0000 | [diff] [blame] | 271 | .PP |
| 272 | And a cast of thousands. |
Guido van Rossum | 74faed2 | 1996-07-30 19:27:05 +0000 | [diff] [blame] | 273 | .SH INTERNET RESOURCES |
| 274 | Web site: http://www.python.org |
| 275 | .br |
| 276 | FTP site: ftp://ftp.python.org |
| 277 | .br |
Fred Drake | 4c9be9d | 1999-08-20 13:10:20 +0000 | [diff] [blame] | 278 | Newsgroups: comp.lang.python, comp.lang.python.announce |
| 279 | .PP |
| 280 | There are many mirror sites; a current list is available at |
| 281 | http://www.python.org/mirrors.html. |
| 282 | .PP |
| 283 | The \fI\Python Software Activity\fP provides many mailing lists which |
| 284 | serve various special interests within the Python community; |
| 285 | information on these special interest groups is available at |
| 286 | http://www.python.org/sigs/. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 287 | .SH COPYRIGHT |
Guido van Rossum | 227a0a1 | 1995-01-04 19:21:21 +0000 | [diff] [blame] | 288 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 289 | The Netherlands. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 290 | .IP " " |
| 291 | All Rights Reserved |
| 292 | .PP |
Guido van Rossum | 227a0a1 | 1995-01-04 19:21:21 +0000 | [diff] [blame] | 293 | Permission to use, copy, modify, and distribute this software and its |
| 294 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 295 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | 227a0a1 | 1995-01-04 19:21:21 +0000 | [diff] [blame] | 296 | both that copyright notice and this permission notice appear in |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 297 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 298 | Centrum or CWI or Corporation for National Research Initiatives or |
| 299 | CNRI not be used in advertising or publicity pertaining to |
| 300 | distribution of the software without specific, written prior |
| 301 | permission. |
Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame] | 302 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 303 | While CWI is the initial source for this software, a modified version |
| 304 | is made available by the Corporation for National Research Initiatives |
| 305 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 306 | |
| 307 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 308 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 309 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 310 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 311 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 312 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 313 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 314 | PERFORMANCE OF THIS SOFTWARE. |