Fred Drake | 3a0351c | 1998-04-04 07:23:21 +0000 | [diff] [blame] | 1 | \section{Built-in Module \module{sys}} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 2 | \declaremodule{builtin}{sys} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 3 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 4 | \modulesynopsis{Access system specific parameters and functions.} |
| 5 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 6 | This module provides access to some variables used or maintained by the |
| 7 | interpreter and to functions that interact strongly with the interpreter. |
| 8 | It is always available. |
| 9 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 10 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 11 | \begin{datadesc}{argv} |
| 12 | The list of command line arguments passed to a Python script. |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 13 | \code{argv[0]} is the script name (it is operating system |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 14 | dependent whether this is a full pathname or not). |
| 15 | If the command was executed using the \samp{-c} command line option |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 16 | to the interpreter, \code{argv[0]} is set to the string |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 17 | \code{'-c'}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 18 | If no script name was passed to the Python interpreter, |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 19 | \code{argv} has zero length. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 20 | \end{datadesc} |
| 21 | |
| 22 | \begin{datadesc}{builtin_module_names} |
Guido van Rossum | 0d2971b | 1997-01-06 23:01:02 +0000 | [diff] [blame] | 23 | A tuple of strings giving the names of all modules that are compiled |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 24 | into this Python interpreter. (This information is not available in |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 25 | any other way --- \code{modules.keys()} only lists the imported |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 26 | modules.) |
| 27 | \end{datadesc} |
| 28 | |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 29 | \begin{datadesc}{copyright} |
| 30 | A string containing the copyright pertaining to the Python interpreter. |
| 31 | \end{datadesc} |
| 32 | |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 33 | \begin{funcdesc}{exc_info}{} |
| 34 | This function returns a tuple of three values that give information |
| 35 | about the exception that is currently being handled. The information |
| 36 | returned is specific both to the current thread and to the current |
| 37 | stack frame. If the current stack frame is not handling an exception, |
| 38 | the information is taken from the calling stack frame, or its caller, |
| 39 | and so on until a stack frame is found that is handling an exception. |
| 40 | Here, ``handling an exception'' is defined as ``executing or having |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 41 | executed an except clause.'' For any stack frame, only |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 42 | information about the most recently handled exception is accessible. |
| 43 | |
| 44 | If no exception is being handled anywhere on the stack, a tuple |
| 45 | containing three \code{None} values is returned. Otherwise, the |
| 46 | values returned are |
| 47 | \code{(\var{type}, \var{value}, \var{traceback})}. |
| 48 | Their meaning is: \var{type} gets the exception type of the exception |
| 49 | being handled (a string or class object); \var{value} gets the |
| 50 | exception parameter (its \dfn{associated value} or the second argument |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 51 | to \keyword{raise}, which is always a class instance if the exception |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 52 | type is a class object); \var{traceback} gets a traceback object (see |
| 53 | the Reference Manual) which encapsulates the call stack at the point |
| 54 | where the exception originally occurred. |
| 55 | \obindex{traceback} |
| 56 | |
| 57 | \strong{Warning:} assigning the \var{traceback} return value to a |
| 58 | local variable in a function that is handling an exception will cause |
| 59 | a circular reference. This will prevent anything referenced by a local |
| 60 | variable in the same function or by the traceback from being garbage |
| 61 | collected. Since most functions don't need access to the traceback, |
| 62 | the best solution is to use something like |
| 63 | \code{type, value = sys.exc_info()[:2]} |
| 64 | to extract only the exception type and value. If you do need the |
| 65 | traceback, make sure to delete it after use (best done with a |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 66 | \keyword{try} ... \keyword{finally} statement) or to call |
| 67 | \function{exc_info()} in a function that does not itself handle an |
| 68 | exception. |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 69 | \end{funcdesc} |
| 70 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 71 | \begin{datadesc}{exc_type} |
| 72 | \dataline{exc_value} |
| 73 | \dataline{exc_traceback} |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 74 | \deprecated {1.5} |
| 75 | {Use \function{exc_info()} instead.} |
| 76 | Since they are global variables, they are not specific to the current |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 77 | thread, so their use is not safe in a multi-threaded program. When no |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 78 | exception is being handled, \code{exc_type} is set to \code{None} and |
| 79 | the other two are undefined. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 80 | \end{datadesc} |
| 81 | |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 82 | \begin{datadesc}{exec_prefix} |
| 83 | A string giving the site-specific |
| 84 | directory prefix where the platform-dependent Python files are |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 85 | installed; by default, this is also \code{'/usr/local'}. This can be |
Fred Drake | f76abb5 | 1998-03-27 00:37:40 +0000 | [diff] [blame] | 86 | set at build time with the \code{-}\code{-exec-prefix} argument to the |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 87 | \program{configure} script. Specifically, all configuration files |
| 88 | (e.g. the \file{config.h} header file) are installed in the directory |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 89 | \code{exec_prefix + '/lib/python\var{version}/config'}, and shared library |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 90 | modules are installed in |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 91 | \code{exec_prefix + '/lib/python\var{version}/lib-dynload'}, |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 92 | where \var{version} is equal to \code{version[:3]}. |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 93 | \end{datadesc} |
| 94 | |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 95 | \begin{datadesc}{executable} |
| 96 | A string giving the name of the executable binary for the Python |
| 97 | interpreter, on systems where this makes sense. |
| 98 | \end{datadesc} |
| 99 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 100 | \begin{funcdesc}{exit}{n} |
| 101 | Exit from Python with numeric exit status \var{n}. This is |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 102 | implemented by raising the \exception{SystemExit} exception, so cleanup |
| 103 | actions specified by finally clauses of \keyword{try} statements |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 104 | are honored, and it is possible to catch the exit attempt at an outer |
| 105 | level. |
| 106 | \end{funcdesc} |
| 107 | |
| 108 | \begin{datadesc}{exitfunc} |
| 109 | This value is not actually defined by the module, but can be set by |
| 110 | the user (or by a program) to specify a clean-up action at program |
| 111 | exit. When set, it should be a parameterless function. This function |
Guido van Rossum | 6b686e9 | 1995-07-07 23:00:35 +0000 | [diff] [blame] | 112 | will be called when the interpreter exits in any way (except when a |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 113 | fatal error occurs: in that case the interpreter's internal state |
| 114 | cannot be trusted). |
| 115 | \end{datadesc} |
| 116 | |
Guido van Rossum | 6e91c6a | 1998-02-07 21:17:05 +0000 | [diff] [blame] | 117 | \begin{funcdesc}{getrefcount}{object} |
| 118 | Return the reference count of the \var{object}. The count returned is |
| 119 | generally one higher than you might expect, because it includes the |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 120 | (temporary) reference as an argument to \function{getrefcount()}. |
Guido van Rossum | 6e91c6a | 1998-02-07 21:17:05 +0000 | [diff] [blame] | 121 | \end{funcdesc} |
| 122 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 123 | \begin{datadesc}{last_type} |
| 124 | \dataline{last_value} |
| 125 | \dataline{last_traceback} |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 126 | These three variables are not always defined; they are set when an |
| 127 | exception is not handled and the interpreter prints an error message |
| 128 | and a stack traceback. Their intended use is to allow an interactive |
| 129 | user to import a debugger module and engage in post-mortem debugging |
| 130 | without having to re-execute the command that caused the error. |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 131 | (Typical use is \samp{import pdb; pdb.pm()} to enter the post-mortem |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 132 | debugger; see the chapter ``The Python Debugger'' for more |
| 133 | information.) |
Fred Drake | 54820dc | 1997-12-15 21:56:05 +0000 | [diff] [blame] | 134 | \refstmodindex{pdb} |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 135 | |
| 136 | The meaning of the variables is the same |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 137 | as that of the return values from \function{exc_info()} above. |
Guido van Rossum | 871cf16 | 1997-10-20 22:38:43 +0000 | [diff] [blame] | 138 | (Since there is only one interactive thread, thread-safety is not a |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 139 | concern for these variables, unlike for \code{exc_type} etc.) |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 140 | \end{datadesc} |
| 141 | |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 142 | \begin{datadesc}{maxint} |
| 143 | The largest positive integer supported by Python's regular integer |
| 144 | type. This is at least 2**31-1. The largest negative integer is |
| 145 | \code{-maxint-1} -- the asymmetry results from the use of 2's |
| 146 | complement binary arithmetic. |
| 147 | \end{datadesc} |
| 148 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 149 | \begin{datadesc}{modules} |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 150 | This is a dictionary that maps module names to modules which have |
| 151 | already been loaded. This can be manipulated to force reloading of |
| 152 | modules and other tricks. Note that removing a module from this |
| 153 | dictionary is \emph{not} the same as calling |
| 154 | \function{reload()}\bifuncindex{reload} on the corresponding module |
| 155 | object. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 156 | \end{datadesc} |
| 157 | |
| 158 | \begin{datadesc}{path} |
Fred Drake | 2b67bee | 1998-01-13 18:35:51 +0000 | [diff] [blame] | 159 | \indexiii{module}{search}{path} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 160 | A list of strings that specifies the search path for modules. |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 161 | Initialized from the environment variable \envvar{PYTHONPATH}, or an |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 162 | installation-dependent default. |
| 163 | |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 164 | The first item of this list, \code{path[0]}, is the |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 165 | directory containing the script that was used to invoke the Python |
| 166 | interpreter. If the script directory is not available (e.g. if the |
| 167 | interpreter is invoked interactively or if the script is read from |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 168 | standard input), \code{path[0]} is the empty string, which directs |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 169 | Python to search modules in the current directory first. Notice that |
Fred Drake | 54820dc | 1997-12-15 21:56:05 +0000 | [diff] [blame] | 170 | the script directory is inserted \emph{before} the entries inserted as |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 171 | a result of \envvar{PYTHONPATH}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 172 | \end{datadesc} |
| 173 | |
Guido van Rossum | 6b686e9 | 1995-07-07 23:00:35 +0000 | [diff] [blame] | 174 | \begin{datadesc}{platform} |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 175 | This string contains a platform identifier, e.g. \code{'sunos5'} or |
| 176 | \code{'linux1'}. This can be used to append platform-specific |
| 177 | components to \code{path}, for instance. |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 178 | \end{datadesc} |
| 179 | |
| 180 | \begin{datadesc}{prefix} |
| 181 | A string giving the site-specific directory prefix where the platform |
| 182 | independent Python files are installed; by default, this is the string |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 183 | \code{'/usr/local'}. This can be set at build time with the |
Fred Drake | f76abb5 | 1998-03-27 00:37:40 +0000 | [diff] [blame] | 184 | \code{-}\code{-prefix} argument to the \program{configure} script. The main |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 185 | collection of Python library modules is installed in the directory |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 186 | \code{prefix + '/lib/python\var{version}'} while the platform |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 187 | independent header files (all except \file{config.h}) are stored in |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 188 | \code{prefix + '/include/python\var{version}'}, |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 189 | where \var{version} is equal to \code{version[:3]}. |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 190 | |
Guido van Rossum | 6b686e9 | 1995-07-07 23:00:35 +0000 | [diff] [blame] | 191 | \end{datadesc} |
| 192 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 193 | \begin{datadesc}{ps1} |
| 194 | \dataline{ps2} |
Fred Drake | e6cedb3 | 1998-04-03 07:05:16 +0000 | [diff] [blame] | 195 | \index{interpreter prompts} |
| 196 | \index{prompts, interpreter} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 197 | Strings specifying the primary and secondary prompt of the |
| 198 | interpreter. These are only defined if the interpreter is in |
| 199 | interactive mode. Their initial values in this case are |
Guido van Rossum | ee9f820 | 1997-11-25 21:12:27 +0000 | [diff] [blame] | 200 | \code{'>>> '} and \code{'... '}. If a non-string object is assigned |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 201 | to either variable, its \function{str()} is re-evaluated each time |
| 202 | the interpreter prepares to read a new interactive command; this can |
| 203 | be used to implement a dynamic prompt. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 204 | \end{datadesc} |
| 205 | |
Guido van Rossum | 9c51e41 | 1995-01-10 10:50:58 +0000 | [diff] [blame] | 206 | \begin{funcdesc}{setcheckinterval}{interval} |
| 207 | Set the interpreter's ``check interval''. This integer value |
| 208 | determines how often the interpreter checks for periodic things such |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 209 | as thread switches and signal handlers. The default is \code{10}, meaning |
Guido van Rossum | 9c51e41 | 1995-01-10 10:50:58 +0000 | [diff] [blame] | 210 | the check is performed every 10 Python virtual instructions. Setting |
| 211 | it to a larger value may increase performance for programs using |
Guido van Rossum | f259efe | 1997-11-25 01:00:40 +0000 | [diff] [blame] | 212 | threads. Setting it to a value \code{<=} 0 checks every virtual instruction, |
Guido van Rossum | 9c51e41 | 1995-01-10 10:50:58 +0000 | [diff] [blame] | 213 | maximizing responsiveness as well as overhead. |
Guido van Rossum | 7f49b7a | 1995-01-12 12:38:46 +0000 | [diff] [blame] | 214 | \end{funcdesc} |
Guido van Rossum | 9c51e41 | 1995-01-10 10:50:58 +0000 | [diff] [blame] | 215 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 216 | \begin{funcdesc}{setprofile}{profilefunc} |
| 217 | Set the system's profile function, which allows you to implement a |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 218 | Python source code profiler in Python. See the chapter on the |
| 219 | Python Profiler. The system's profile function |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 220 | is called similarly to the system's trace function (see |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 221 | \function{settrace()}), but it isn't called for each executed line of |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 222 | code (only on call and return and when an exception occurs). Also, |
| 223 | its return value is not used, so it can just return \code{None}. |
| 224 | \end{funcdesc} |
| 225 | \index{profile function} |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 226 | \index{profiler} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 227 | |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 228 | \begin{funcdesc}{settrace}{tracefunc} |
| 229 | Set the system's trace function, which allows you to implement a |
| 230 | Python source code debugger in Python. See section ``How It Works'' |
| 231 | in the chapter on the Python Debugger. |
| 232 | \end{funcdesc} |
| 233 | \index{trace function} |
| 234 | \index{debugger} |
| 235 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 236 | \begin{datadesc}{stdin} |
| 237 | \dataline{stdout} |
| 238 | \dataline{stderr} |
| 239 | File objects corresponding to the interpreter's standard input, |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 240 | output and error streams. \code{stdin} is used for all |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 241 | interpreter input except for scripts but including calls to |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 242 | \function{input()}\bifuncindex{input} and |
| 243 | \function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is used |
| 244 | for the output of \keyword{print} and expression statements and for the |
| 245 | prompts of \function{input()} and \function{raw_input()}. The interpreter's |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 246 | own prompts and (almost all of) its error messages go to |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 247 | \code{stderr}. \code{stdout} and \code{stderr} needn't |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 248 | be built-in file objects: any object is acceptable as long as it has |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 249 | a \method{write()} method that takes a string argument. (Changing these |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 250 | objects doesn't affect the standard I/O streams of processes |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 251 | executed by \function{os.popen()}, \function{os.system()} or the |
| 252 | \function{exec*()} family of functions in the \module{os} module.) |
Fred Drake | 54820dc | 1997-12-15 21:56:05 +0000 | [diff] [blame] | 253 | \refstmodindex{os} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 254 | \end{datadesc} |
| 255 | |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 256 | \begin{datadesc}{__stdin__} |
| 257 | \dataline{__stdout__} |
| 258 | \dataline{__stderr__} |
| 259 | These objects contain the original values of \code{stdin}, |
| 260 | \code{stderr} and \code{stdout} at the start of the program. They are |
| 261 | used during finalization, and could be useful to restore the actual |
| 262 | files to known working file objects in case they have been overwritten |
| 263 | with a broken object. |
| 264 | \end{datadesc} |
| 265 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 266 | \begin{datadesc}{tracebacklimit} |
| 267 | When this variable is set to an integer value, it determines the |
| 268 | maximum number of levels of traceback information printed when an |
Fred Drake | 0fd72ee | 1998-03-08 05:43:51 +0000 | [diff] [blame] | 269 | unhandled exception occurs. The default is \code{1000}. When set to |
| 270 | 0 or less, all traceback information is suppressed and only the |
| 271 | exception type and value are printed. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 272 | \end{datadesc} |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 273 | |
| 274 | \begin{datadesc}{version} |
Guido van Rossum | 3e5fe42 | 1998-06-10 17:57:44 +0000 | [diff] [blame] | 275 | A string containing the version number of the Python interpreter. |
Guido van Rossum | 0a3c753 | 1997-06-02 17:32:41 +0000 | [diff] [blame] | 276 | \end{datadesc} |