Guido van Rossum | a7925f1 | 1994-01-26 10:20:16 +0000 | [diff] [blame^] | 1 | .TH PYTHON "3 January 1994" |
| 2 | .SH NAME |
| 3 | python \- an interpreted, interactive, object-oriented programming language |
| 4 | .SH SYNOPSIS |
| 5 | .B python |
| 6 | [ |
| 7 | .I X11-options |
| 8 | ] |
| 9 | [ |
| 10 | .B \-d |
| 11 | ] |
| 12 | [ |
| 13 | .B \-i |
| 14 | ] |
| 15 | [ |
| 16 | .B \-k |
| 17 | ] |
| 18 | [ |
| 19 | .B \-v |
| 20 | ] |
| 21 | [ |
| 22 | .B \-c |
| 23 | .I command |
| 24 | | |
| 25 | .I script |
| 26 | | |
| 27 | \- |
| 28 | ] |
| 29 | [ |
| 30 | .I arguments |
| 31 | ] |
| 32 | .SH DESCRIPTION |
| 33 | Python is an interpreted, interactive, object-oriented programming |
| 34 | language that combines remarkable power with very clear syntax. |
| 35 | For an introduction to programming in Python you are referred to the |
| 36 | Python Tutorial. |
| 37 | The Python Library Reference documents built-in and standard types, |
| 38 | constants, functions and modules. |
| 39 | Finally, the Python Reference Manual describes the syntax and |
| 40 | semantics of the core language in (perhaps too) much detail. |
| 41 | .PP |
| 42 | Python's basic power can be extended with your own modules written in |
| 43 | C or C++. |
| 44 | On some (most?) systems such modules may be dynamically loaded. |
| 45 | Python is also adaptable as an extension language for existing |
| 46 | applications. |
| 47 | See the internal documentation for hints. |
| 48 | .SH COMMAND LINE OPTIONS |
| 49 | .TP |
| 50 | .TP |
| 51 | .B \-d |
| 52 | Turn on parser debugging output (for wizards only, depending on |
| 53 | compilation options). |
| 54 | .B \-i |
| 55 | When a script is passed as first argument or the \fB\-c\fP option is |
| 56 | used, enter interactive mode after executing the script or the |
| 57 | command. This can be useful to inspect global variables or a stack |
| 58 | trace when a script raises an exception. |
| 59 | .TP |
| 60 | .B \-i |
| 61 | When executing a program from a file, this option enters interactive |
| 62 | mode after the program has completed. It does not read the |
| 63 | $PYTHONSTARTUP file. |
| 64 | .TP |
| 65 | .B \-k |
| 66 | This hack, eh, feature is intended to help you to find expression |
| 67 | statements that print a value. Although a feature of the language, it |
| 68 | can sometimes be annoying that when a function is called which returns |
| 69 | a value that is not |
| 70 | .IR None , |
| 71 | the value is printed to standard output, and it is not always easy to |
| 72 | find which statement is the cause of an unwanted `1', for instance. |
| 73 | When this option is set, if an expression statement prints its value, |
| 74 | the exception |
| 75 | .I RuntimeError |
| 76 | is raised. The resulting stack trace will help you to track down the |
| 77 | culprit. |
| 78 | .TP |
| 79 | .B \-v |
| 80 | Print a message each time a module is initialized, showing the place |
| 81 | (filename or built-in module) from which it is loaded. |
| 82 | .TP |
| 83 | .BI "\-c " command |
| 84 | Specify the command to execute (see next section). |
| 85 | This terminates the option list (following options are passed as |
| 86 | arguments to the command). |
| 87 | .PP |
| 88 | When the interpreter is configured to contain the |
| 89 | .I stdwin |
| 90 | built-in module for use with the X window system, additional command |
| 91 | line options common to most X applications are recognized (by STDWIN), |
| 92 | e.g. |
| 93 | .B \-display |
| 94 | .I displayname |
| 95 | and |
| 96 | .B \-geometry |
| 97 | .I widthxheight+x+y. |
| 98 | The complete set of options is described in the STDWIN documentation. |
| 99 | .SH INTERPRETER INTERFACE |
| 100 | The interpreter interface resembles that of the UNIX shell: when |
| 101 | called with standard input connected to a tty device, it prompts for |
| 102 | commands and executes them until an EOF is read; when called with a |
| 103 | file name argument or with a file as standard input, it reads and |
| 104 | executes a |
| 105 | .I script |
| 106 | from that file; |
| 107 | when called with |
| 108 | .B \-c |
| 109 | .I command, |
| 110 | it executes the Python statement(s) given as |
| 111 | .I command. |
| 112 | Here |
| 113 | .I command |
| 114 | may contain multiple statements separated by newlines. |
| 115 | Leading whitespace is significant in Python statements! |
| 116 | In non-interactive mode, the entire input is parsed befored it is |
| 117 | executed. |
| 118 | .PP |
| 119 | If available, the script name and additional arguments thereafter are |
| 120 | passed to the script in the Python variable |
| 121 | .I sys.argv , |
| 122 | which is a list of strings (you must first |
| 123 | .I import sys |
| 124 | to be able to access it). |
| 125 | If no script name is given, |
| 126 | .I sys.argv |
| 127 | is empty; if |
| 128 | .B \-c |
| 129 | is used, |
| 130 | .I sys.argv[0] |
| 131 | contains the string |
| 132 | .I '-c'. |
| 133 | Note that options interpreter by the Python interpreter or by STDWIN |
| 134 | are not placed in |
| 135 | .I sys.argv. |
| 136 | .PP |
| 137 | In interactive mode, the primary prompt is `>>>'; the second prompt |
| 138 | (which appears when a command is not complete) is `...'. |
| 139 | The prompts can be changed by assignment to |
| 140 | .I sys.ps1 |
| 141 | or |
| 142 | .I sys.ps2. |
| 143 | The interpreter quits when it reads an EOF at a prompt. |
| 144 | When an unhandled exception occurs, a stack trace is printed and |
| 145 | control returns to the primary prompt; in non-interactive mode, the |
| 146 | interpreter exits after printing the stack trace. |
| 147 | The interrupt signal raises the |
| 148 | .I Keyboard\%Interrupt |
| 149 | exception; other UNIX signals are not caught (except that SIGPIPE is |
| 150 | sometimes ignored, in favor of the |
| 151 | .I IOError |
| 152 | exception). Error messages are written to stderr. |
| 153 | .SH FILES AND DIRECTORIES |
| 154 | These are subject to difference depending on local installation |
| 155 | conventions: |
| 156 | .IP /usr/local/bin/python |
| 157 | Recommended location of the interpreter. |
| 158 | .IP /usr/local/lib/python |
| 159 | Recommended location of the directory containing the standard modules. |
| 160 | .SH ENVIRONMENT VARIABLES |
| 161 | .IP PYTHONPATH |
| 162 | Augments the default search path for module files. |
| 163 | The format is the same as the shell's $PATH: one or more directory |
| 164 | pathnames separated by colons. |
| 165 | Non-existant directories are silently ignored. |
| 166 | The default search path is installation dependent, but always begins |
| 167 | with `.', (for example, |
| 168 | .I .:/usr/local/lib/python ). |
| 169 | The default search path is appended to $PYTHONPATH. |
| 170 | The search path can be manipulated from within a Python program as the |
| 171 | variable |
| 172 | .I sys.path . |
| 173 | .IP PYTHONSTARTUP |
| 174 | If this is the name of a readable file, the Python commands in that |
| 175 | file are executed before the first prompt is displayed in interactive |
| 176 | mode. |
| 177 | The file is executed in the same name space where interactive commands |
| 178 | are executed so that objects defined or imported in it can be used |
| 179 | without qualification in the interactive session. |
| 180 | You can also change the prompts |
| 181 | .I sys.ps1 |
| 182 | and |
| 183 | .I sys.ps2 |
| 184 | in this file. |
| 185 | .IP PYTHONDEBUG |
| 186 | If this is set to a non-empty string it is equivalent to specifying |
| 187 | the \fB\-d\fP option. |
| 188 | .IP PYTHONINSPECT |
| 189 | If this is set to a non-empty string it is equivalent to specifying |
| 190 | the \fB\-i\fP option. |
| 191 | .IP PYTHONKILLPRINT |
| 192 | If this is set to a non-empty string it is equivalent to specifying |
| 193 | the \fB\-k\fP option. |
| 194 | .IP PYTHONVERBOSE |
| 195 | If this is set to a non-empty string it is equivalent to specifying |
| 196 | the \fB\-v\fP option. |
| 197 | .SH SEE ALSO |
| 198 | Python Tutorial |
| 199 | .br |
| 200 | Python Library Reference |
| 201 | .br |
| 202 | Python Reference Manual |
| 203 | .br |
| 204 | STDWIN under X11 |
| 205 | .SH BUGS AND CAVEATS |
| 206 | The first time |
| 207 | .I stdwin |
| 208 | is imported, it initializes the STDWIN library. |
| 209 | If this initialization fails, e.g. because the display connection |
| 210 | fails, the interpreter aborts immediately. |
| 211 | .SH AUTHOR |
| 212 | .nf |
| 213 | Guido van Rossum |
| 214 | CWI (Centrum voor Wiskunde en Informatica) |
| 215 | P.O. Box 4079 |
| 216 | 1009 AB Amsterdam |
| 217 | The Netherlands |
| 218 | .PP |
| 219 | E-mail: Guido.van.Rossum@cwi.nl |
| 220 | .fi |
| 221 | .SH MAILING LIST |
| 222 | There is a mailing list devoted to Python programming, bugs and |
| 223 | design. |
| 224 | To subscribe, send mail containing your real name and e-mail address |
| 225 | in Internet form to |
| 226 | .I python-list-request@cwi.nl. |
| 227 | .SH COPYRIGHT |
| 228 | Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum, |
| 229 | Amsterdam, The Netherlands. |
| 230 | .IP " " |
| 231 | All Rights Reserved |
| 232 | .PP |
| 233 | Permission to use, copy, modify, and distribute this software and its |
| 234 | documentation for any purpose and without fee is hereby granted, |
| 235 | provided that the above copyright notice appear in all copies and that |
| 236 | both that copyright notice and this permission notice appear in |
| 237 | supporting documentation, and that the names of Stichting Mathematisch |
| 238 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 239 | distribution of the software without specific, written prior permission. |
| 240 | |
| 241 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 242 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 243 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 244 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 245 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 246 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 247 | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |