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