Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{os} --- |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 2 | Miscellaneous OS interfaces} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | |
Fred Drake | ec6baaf | 1999-04-21 18:13:31 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{os} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | \modulesynopsis{Miscellaneous OS interfaces.} |
| 6 | |
Fred Drake | c4f15af | 1998-03-10 03:17:26 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 8 | This module provides a more portable way of using operating system |
| 9 | (OS) dependent functionality than importing an OS dependent built-in |
Fred Drake | 2f97901 | 1999-06-11 18:28:37 +0000 | [diff] [blame] | 10 | module like \refmodule{posix} or \module{nt}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 11 | |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 12 | This module searches for an OS dependent built-in module like |
Fred Drake | 2f97901 | 1999-06-11 18:28:37 +0000 | [diff] [blame] | 13 | \module{mac} or \refmodule{posix} and exports the same functions and data |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 14 | as found there. The design of all Python's built-in OS dependent |
| 15 | modules is such that as long as the same functionality is available, |
| 16 | it uses the same interface; e.g., the function |
Fred Drake | ec6baaf | 1999-04-21 18:13:31 +0000 | [diff] [blame] | 17 | \code{os.stat(\var{path})} returns stat information about \var{path} in |
| 18 | the same format (which happens to have originated with the |
| 19 | \POSIX{} interface). |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 20 | |
| 21 | Extensions peculiar to a particular OS are also available through the |
Fred Drake | c4f15af | 1998-03-10 03:17:26 +0000 | [diff] [blame] | 22 | \module{os} module, but using them is of course a threat to |
| 23 | portability! |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 24 | |
Fred Drake | c4f15af | 1998-03-10 03:17:26 +0000 | [diff] [blame] | 25 | Note that after the first time \module{os} is imported, there is |
| 26 | \emph{no} performance penalty in using functions from \module{os} |
| 27 | instead of directly from the OS dependent built-in module, so there |
| 28 | should be \emph{no} reason not to use \module{os}! |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 29 | |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 30 | |
Fred Drake | 859dc53 | 1999-07-01 13:54:40 +0000 | [diff] [blame] | 31 | % Frank Stajano <fstajano@uk.research.att.com> complained that it |
| 32 | % wasn't clear that the entries described in the subsections were all |
| 33 | % available at the module level (most uses of subsections are |
| 34 | % different); I think this is only a problem for the HTML version, |
| 35 | % where the relationship may not be as clear. |
| 36 | % |
| 37 | \ifhtml |
| 38 | The \module{os} module contains many functions and data values. |
| 39 | The items below and in the following sub-sections are all available |
| 40 | directly from the \module{os} module. |
| 41 | \fi |
| 42 | |
| 43 | |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 44 | \begin{excdesc}{error} |
| 45 | This exception is raised when a function returns a |
| 46 | system-related error (e.g., not for illegal argument types). This is |
| 47 | also known as the built-in exception \exception{OSError}. The |
| 48 | accompanying value is a pair containing the numeric error code from |
| 49 | \cdata{errno} and the corresponding string, as would be printed by the |
| 50 | C function \cfunction{perror()}. See the module |
| 51 | \refmodule{errno}\refbimodindex{errno}, which contains names for the |
| 52 | error codes defined by the underlying operating system. |
| 53 | |
| 54 | When exceptions are classes, this exception carries two attributes, |
| 55 | \member{errno} and \member{strerror}. The first holds the value of |
| 56 | the C \cdata{errno} variable, and the latter holds the corresponding |
| 57 | error message from \cfunction{strerror()}. For exceptions that |
| 58 | involve a file system path (e.g. \function{chdir()} or |
| 59 | \function{unlink()}), the exception instance will contain a third |
| 60 | attribute, \member{filename}, which is the file name passed to the |
| 61 | function. |
| 62 | |
| 63 | When exceptions are strings, the string for the exception is |
| 64 | \code{'OSError'}. |
| 65 | \end{excdesc} |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 66 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 67 | \begin{datadesc}{name} |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 68 | The name of the OS dependent module imported. The following names |
| 69 | have currently been registered: \code{'posix'}, \code{'nt'}, |
Fred Drake | 2f97901 | 1999-06-11 18:28:37 +0000 | [diff] [blame] | 70 | \code{'dos'}, \code{'mac'}, \code{'os2'}, \code{'ce'}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 71 | \end{datadesc} |
| 72 | |
| 73 | \begin{datadesc}{path} |
| 74 | The corresponding OS dependent standard module for pathname |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 75 | operations, e.g., \module{posixpath} or \module{macpath}. Thus, given |
| 76 | the proper imports, \code{os.path.split(\var{file})} is equivalent to but |
| 77 | more portable than \code{posixpath.split(\var{file})}. Note that this |
| 78 | is also a valid module: it may be imported directly as |
| 79 | \refmodule{os.path}. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 80 | \end{datadesc} |
| 81 | |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 82 | |
| 83 | |
| 84 | \subsection{Process Parameters \label{os-procinfo}} |
| 85 | |
| 86 | These functions and data items provide information and operate on the |
| 87 | current process and user. |
| 88 | |
| 89 | \begin{funcdesc}{chdir}{path} |
Fred Drake | 859dc53 | 1999-07-01 13:54:40 +0000 | [diff] [blame] | 90 | \index{directory!changing} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 91 | Change the current working directory to \var{path}. |
| 92 | Availability: Macintosh, \UNIX{}, Windows. |
| 93 | \end{funcdesc} |
| 94 | |
| 95 | \begin{datadesc}{environ} |
Fred Drake | 0e1de8b | 1999-04-29 12:57:32 +0000 | [diff] [blame] | 96 | A mapping object representing the string environment. For example, |
| 97 | \code{environ['HOME']} is the pathname of your home directory (on some |
| 98 | platforms), and is equivalent to \code{getenv("HOME")} in C. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 99 | |
| 100 | If the platform supports the \function{putenv()} function, this |
| 101 | mapping may be used to modify the environment as well as query the |
| 102 | environment. \function{putenv()} will be called automatically when |
| 103 | the mapping is modified. |
| 104 | |
| 105 | If \function{putenv()} is not provided, this mapping may be passed to |
| 106 | the appropriate process-creation functions to cause child processes to |
| 107 | use a modified environment. |
| 108 | \end{datadesc} |
| 109 | |
| 110 | \begin{funcdesc}{getcwd}{} |
| 111 | Return a string representing the current working directory. |
| 112 | Availability: Macintosh, \UNIX{}, Windows. |
| 113 | \end{funcdesc} |
| 114 | |
| 115 | \begin{funcdesc}{getegid}{} |
| 116 | Return the current process' effective group id. |
| 117 | Availability: \UNIX{}. |
| 118 | \end{funcdesc} |
| 119 | |
| 120 | \begin{funcdesc}{geteuid}{} |
Fred Drake | 6b330ba8 | 1999-05-25 13:42:26 +0000 | [diff] [blame] | 121 | \index{user!effective id} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 122 | Return the current process' effective user id. |
| 123 | Availability: \UNIX{}. |
| 124 | \end{funcdesc} |
| 125 | |
| 126 | \begin{funcdesc}{getgid}{} |
Fred Drake | 6b330ba8 | 1999-05-25 13:42:26 +0000 | [diff] [blame] | 127 | \index{process!group} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 128 | Return the current process' group id. |
| 129 | Availability: \UNIX{}. |
| 130 | \end{funcdesc} |
| 131 | |
| 132 | \begin{funcdesc}{getpgrp}{} |
| 133 | \index{process!group} |
| 134 | Return the current process group id. |
| 135 | Availability: \UNIX{}. |
| 136 | \end{funcdesc} |
| 137 | |
| 138 | \begin{funcdesc}{getpid}{} |
| 139 | \index{process!id} |
| 140 | Return the current process id. |
| 141 | Availability: \UNIX{}, Windows. |
| 142 | \end{funcdesc} |
| 143 | |
| 144 | \begin{funcdesc}{getppid}{} |
| 145 | \index{process!id of parent} |
| 146 | Return the parent's process id. |
| 147 | Availability: \UNIX{}. |
| 148 | \end{funcdesc} |
| 149 | |
| 150 | \begin{funcdesc}{getuid}{} |
Fred Drake | 6b330ba8 | 1999-05-25 13:42:26 +0000 | [diff] [blame] | 151 | \index{user!id} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 152 | Return the current process' user id. |
| 153 | Availability: \UNIX{}. |
| 154 | \end{funcdesc} |
| 155 | |
| 156 | \begin{funcdesc}{putenv}{varname, value} |
| 157 | \index{environment variables!setting} |
| 158 | Set the environment variable named \var{varname} to the string |
| 159 | \var{value}. Such changes to the environment affect subprocesses |
| 160 | started with \function{os.system()}, \function{popen()} or |
| 161 | \function{fork()} and \function{execv()}. |
| 162 | Availability: most flavors of \UNIX{}, Windows. |
| 163 | |
| 164 | When \function{putenv()} is |
| 165 | supported, assignments to items in \code{os.environ} are automatically |
| 166 | translated into corresponding calls to \function{putenv()}; however, |
| 167 | calls to \function{putenv()} don't update \code{os.environ}, so it is |
| 168 | actually preferable to assign to items of \code{os.environ}. |
| 169 | \end{funcdesc} |
| 170 | |
| 171 | \begin{funcdesc}{setgid}{gid} |
| 172 | Set the current process' group id. |
| 173 | Availability: \UNIX{}. |
| 174 | \end{funcdesc} |
| 175 | |
| 176 | \begin{funcdesc}{setpgrp}{} |
| 177 | Calls the system call \cfunction{setpgrp()} or \cfunction{setpgrp(0, |
| 178 | 0)} depending on which version is implemented (if any). See the |
| 179 | \UNIX{} manual for the semantics. |
| 180 | Availability: \UNIX{}. |
| 181 | \end{funcdesc} |
| 182 | |
| 183 | \begin{funcdesc}{setpgid}{pid, pgrp} |
| 184 | Calls the system call \cfunction{setpgid()}. See the \UNIX{} manual |
| 185 | for the semantics. |
| 186 | Availability: \UNIX{}. |
| 187 | \end{funcdesc} |
| 188 | |
| 189 | \begin{funcdesc}{setsid}{} |
| 190 | Calls the system call \cfunction{setsid()}. See the \UNIX{} manual |
| 191 | for the semantics. |
| 192 | Availability: \UNIX{}. |
| 193 | \end{funcdesc} |
| 194 | |
| 195 | \begin{funcdesc}{setuid}{uid} |
Fred Drake | 6b330ba8 | 1999-05-25 13:42:26 +0000 | [diff] [blame] | 196 | \index{user!id, setting} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 197 | Set the current process' user id. |
| 198 | Availability: \UNIX{}. |
| 199 | \end{funcdesc} |
| 200 | |
| 201 | % placed in this section since it relates to errno.... a little weak ;-( |
| 202 | \begin{funcdesc}{strerror}{code} |
| 203 | Return the error message corresponding to the error code in |
| 204 | \var{code}. |
| 205 | Availability: \UNIX{}, Windows. |
| 206 | \end{funcdesc} |
| 207 | |
| 208 | \begin{funcdesc}{umask}{mask} |
| 209 | Set the current numeric umask and returns the previous umask. |
| 210 | Availability: \UNIX{}, Windows. |
| 211 | \end{funcdesc} |
| 212 | |
| 213 | \begin{funcdesc}{uname}{} |
| 214 | Return a 5-tuple containing information identifying the current |
| 215 | operating system. The tuple contains 5 strings: |
| 216 | \code{(\var{sysname}, \var{nodename}, \var{release}, \var{version}, |
| 217 | \var{machine})}. Some systems truncate the nodename to 8 |
| 218 | characters or to the leading component; a better way to get the |
| 219 | hostname is \function{socket.gethostname()} |
| 220 | \withsubitem{(in module socket)}{\ttindex{gethostname()}} |
| 221 | or even |
| 222 | \withsubitem{(in module socket)}{\ttindex{gethostbyaddr()}} |
| 223 | \code{socket.gethostbyaddr(socket.gethostname())}. |
| 224 | Availability: recent flavors of \UNIX{}. |
| 225 | \end{funcdesc} |
| 226 | |
| 227 | |
| 228 | |
| 229 | \subsection{File Object Creation \label{os-newstreams}} |
| 230 | |
| 231 | These functions create new file objects. |
| 232 | |
| 233 | |
| 234 | \begin{funcdesc}{fdopen}{fd\optional{, mode\optional{, bufsize}}} |
| 235 | Return an open file object connected to the file descriptor \var{fd}. |
| 236 | The \var{mode} and \var{bufsize} arguments have the same meaning as |
| 237 | the corresponding arguments to the built-in \function{open()} |
| 238 | function. |
| 239 | Availability: Macintosh, \UNIX{}, Windows. |
| 240 | \end{funcdesc} |
| 241 | |
| 242 | \begin{funcdesc}{popen}{command\optional{, mode\optional{, bufsize}}} |
| 243 | Open a pipe to or from \var{command}. The return value is an open |
| 244 | file object connected to the pipe, which can be read or written |
| 245 | depending on whether \var{mode} is \code{'r'} (default) or \code{'w'}. |
| 246 | The \var{bufsize} argument has the same meaning as the corresponding |
| 247 | argument to the built-in \function{open()} function. The exit status of |
| 248 | the command (encoded in the format specified for \function{wait()}) is |
| 249 | available as the return value of the \method{close()} method of the file |
| 250 | object, except that when the exit status is zero (termination without |
| 251 | errors), \code{None} is returned. |
| 252 | Availability: \UNIX{}, Windows. |
| 253 | \end{funcdesc} |
| 254 | |
| 255 | |
| 256 | |
| 257 | \subsection{File Descriptor Operations \label{os-fd-ops}} |
| 258 | |
| 259 | These functions operate on I/O streams referred to |
| 260 | using file descriptors. |
| 261 | |
| 262 | |
| 263 | \begin{funcdesc}{close}{fd} |
| 264 | Close file descriptor \var{fd}. |
| 265 | Availability: Macintosh, \UNIX{}, Windows. |
| 266 | |
| 267 | Note: this function is intended for low-level I/O and must be applied |
| 268 | to a file descriptor as returned by \function{open()} or |
| 269 | \function{pipe()}. To close a ``file object'' returned by the |
| 270 | built-in function \function{open()} or by \function{popen()} or |
| 271 | \function{fdopen()}, use its \method{close()} method. |
| 272 | \end{funcdesc} |
| 273 | |
| 274 | \begin{funcdesc}{dup}{fd} |
| 275 | Return a duplicate of file descriptor \var{fd}. |
| 276 | Availability: Macintosh, \UNIX{}, Windows. |
| 277 | \end{funcdesc} |
| 278 | |
| 279 | \begin{funcdesc}{dup2}{fd, fd2} |
| 280 | Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter |
| 281 | first if necessary. |
| 282 | Availability: \UNIX{}, Windows. |
| 283 | \end{funcdesc} |
| 284 | |
| 285 | \begin{funcdesc}{fstat}{fd} |
| 286 | Return status for file descriptor \var{fd}, like \function{stat()}. |
| 287 | Availability: \UNIX{}, Windows. |
| 288 | \end{funcdesc} |
| 289 | |
| 290 | \begin{funcdesc}{fstatvfs}{fd} |
| 291 | Return information about the filesystem containing the file associated |
| 292 | with file descriptor \var{fd}, like \function{statvfs()}. |
| 293 | Availability: \UNIX{}. |
| 294 | \end{funcdesc} |
| 295 | |
| 296 | \begin{funcdesc}{ftruncate}{fd, length} |
| 297 | Truncate the file corresponding to file descriptor \var{fd}, |
| 298 | so that it is at most \var{length} bytes in size. |
| 299 | Availability: \UNIX{}. |
| 300 | \end{funcdesc} |
| 301 | |
| 302 | \begin{funcdesc}{lseek}{fd, pos, how} |
| 303 | Set the current position of file descriptor \var{fd} to position |
| 304 | \var{pos}, modified by \var{how}: \code{0} to set the position |
| 305 | relative to the beginning of the file; \code{1} to set it relative to |
| 306 | the current position; \code{2} to set it relative to the end of the |
| 307 | file. |
| 308 | Availability: Macintosh, \UNIX{}, Windows. |
| 309 | \end{funcdesc} |
| 310 | |
| 311 | \begin{funcdesc}{open}{file, flags\optional{, mode}} |
| 312 | Open the file \var{file} and set various flags according to |
| 313 | \var{flags} and possibly its mode according to \var{mode}. |
| 314 | The default \var{mode} is \code{0777} (octal), and the current umask |
| 315 | value is first masked out. Return the file descriptor for the newly |
| 316 | opened file. |
| 317 | Availability: Macintosh, \UNIX{}, Windows. |
| 318 | |
| 319 | For a description of the flag and mode values, see the C run-time |
| 320 | documentation; flag constants (like \constant{O_RDONLY} and |
| 321 | \constant{O_WRONLY}) are defined in this module too (see below). |
| 322 | |
| 323 | Note: this function is intended for low-level I/O. For normal usage, |
| 324 | use the built-in function \function{open()}, which returns a ``file |
| 325 | object'' with \method{read()} and \method{write()} methods (and many |
| 326 | more). |
| 327 | \end{funcdesc} |
| 328 | |
| 329 | \begin{funcdesc}{pipe}{} |
| 330 | Create a pipe. Return a pair of file descriptors \code{(\var{r}, |
| 331 | \var{w})} usable for reading and writing, respectively. |
| 332 | Availability: \UNIX{}, Windows. |
| 333 | \end{funcdesc} |
| 334 | |
| 335 | \begin{funcdesc}{read}{fd, n} |
| 336 | Read at most \var{n} bytes from file descriptor \var{fd}. |
| 337 | Return a string containing the bytes read. |
| 338 | Availability: Macintosh, \UNIX{}, Windows. |
| 339 | |
| 340 | Note: this function is intended for low-level I/O and must be applied |
| 341 | to a file descriptor as returned by \function{open()} or |
| 342 | \function{pipe()}. To read a ``file object'' returned by the |
| 343 | built-in function \function{open()} or by \function{popen()} or |
| 344 | \function{fdopen()}, or \code{sys.stdin}, use its |
| 345 | \method{read()} or \method{readline()} methods. |
| 346 | \end{funcdesc} |
| 347 | |
| 348 | \begin{funcdesc}{tcgetpgrp}{fd} |
| 349 | Return the process group associated with the terminal given by |
| 350 | \var{fd} (an open file descriptor as returned by \function{open()}). |
| 351 | Availability: \UNIX{}. |
| 352 | \end{funcdesc} |
| 353 | |
| 354 | \begin{funcdesc}{tcsetpgrp}{fd, pg} |
| 355 | Set the process group associated with the terminal given by |
| 356 | \var{fd} (an open file descriptor as returned by \function{open()}) |
| 357 | to \var{pg}. |
| 358 | Availability: \UNIX{}. |
| 359 | \end{funcdesc} |
| 360 | |
| 361 | \begin{funcdesc}{ttyname}{fd} |
| 362 | Return a string which specifies the terminal device associated with |
| 363 | file-descriptor \var{fd}. If \var{fd} is not associated with a terminal |
| 364 | device, an exception is raised. |
| 365 | Availability: \UNIX{}. |
| 366 | \end{funcdesc} |
| 367 | |
| 368 | \begin{funcdesc}{write}{fd, str} |
| 369 | Write the string \var{str} to file descriptor \var{fd}. |
| 370 | Return the number of bytes actually written. |
| 371 | Availability: Macintosh, \UNIX{}, Windows. |
| 372 | |
| 373 | Note: this function is intended for low-level I/O and must be applied |
| 374 | to a file descriptor as returned by \function{open()} or |
| 375 | \function{pipe()}. To write a ``file object'' returned by the |
| 376 | built-in function \function{open()} or by \function{popen()} or |
| 377 | \function{fdopen()}, or \code{sys.stdout} or \code{sys.stderr}, use |
| 378 | its \method{write()} method. |
| 379 | \end{funcdesc} |
| 380 | |
| 381 | |
| 382 | The following data items are available for use in constructing the |
| 383 | \var{flags} parameter to the \function{open()} function. |
| 384 | |
| 385 | \begin{datadesc}{O_RDONLY} |
| 386 | \dataline{O_WRONLY} |
| 387 | \dataline{O_RDWR} |
| 388 | \dataline{O_NDELAY} |
| 389 | \dataline{O_NONBLOCK} |
| 390 | \dataline{O_APPEND} |
| 391 | \dataline{O_DSYNC} |
| 392 | \dataline{O_RSYNC} |
| 393 | \dataline{O_SYNC} |
| 394 | \dataline{O_NOCTTY} |
| 395 | \dataline{O_CREAT} |
| 396 | \dataline{O_EXCL} |
| 397 | \dataline{O_TRUNC} |
| 398 | Options for the \var{flag} argument to the \function{open()} function. |
| 399 | These can be bit-wise OR'd together. |
| 400 | Availability: Macintosh, \UNIX{}, Windows. |
| 401 | \end{datadesc} |
| 402 | |
| 403 | |
| 404 | \subsection{Files and Directories \label{os-file-dir}} |
| 405 | |
| 406 | \begin{funcdesc}{access}{path, mode} |
| 407 | Check read/write/execute permissions for this process or extance of file |
| 408 | \var{path}. Return \code{1} if access is granted, \code{0} if not. |
| 409 | See the \UNIX{} manual for the semantics. |
| 410 | Availability: \UNIX{}. |
| 411 | \end{funcdesc} |
| 412 | |
| 413 | \begin{funcdesc}{chmod}{path, mode} |
| 414 | Change the mode of \var{path} to the numeric \var{mode}. |
| 415 | Availability: \UNIX{}, Windows. |
| 416 | \end{funcdesc} |
| 417 | |
| 418 | \begin{funcdesc}{chown}{path, uid, gid} |
| 419 | Change the owner and group id of \var{path} to the numeric \var{uid} |
| 420 | and \var{gid}. |
| 421 | Availability: \UNIX{}. |
| 422 | \end{funcdesc} |
| 423 | |
| 424 | \begin{funcdesc}{link}{src, dst} |
| 425 | Create a hard link pointing to \var{src} named \var{dst}. |
| 426 | Availability: \UNIX{}. |
| 427 | \end{funcdesc} |
| 428 | |
| 429 | \begin{funcdesc}{listdir}{path} |
| 430 | Return a list containing the names of the entries in the directory. |
| 431 | The list is in arbitrary order. It does not include the special |
| 432 | entries \code{'.'} and \code{'..'} even if they are present in the |
| 433 | directory. |
| 434 | Availability: Macintosh, \UNIX{}, Windows. |
| 435 | \end{funcdesc} |
| 436 | |
| 437 | \begin{funcdesc}{lstat}{path} |
| 438 | Like \function{stat()}, but do not follow symbolic links. |
| 439 | Availability: \UNIX{}. |
| 440 | \end{funcdesc} |
| 441 | |
| 442 | \begin{funcdesc}{mkfifo}{path\optional{, mode}} |
| 443 | Create a FIFO (a named pipe) named \var{path} with numeric mode |
| 444 | \var{mode}. The default \var{mode} is \code{0666} (octal). The current |
| 445 | umask value is first masked out from the mode. |
| 446 | Availability: \UNIX{}. |
| 447 | |
| 448 | FIFOs are pipes that can be accessed like regular files. FIFOs exist |
| 449 | until they are deleted (for example with \function{os.unlink()}). |
| 450 | Generally, FIFOs are used as rendezvous between ``client'' and |
| 451 | ``server'' type processes: the server opens the FIFO for reading, and |
| 452 | the client opens it for writing. Note that \function{mkfifo()} |
| 453 | doesn't open the FIFO --- it just creates the rendezvous point. |
| 454 | \end{funcdesc} |
| 455 | |
| 456 | \begin{funcdesc}{mkdir}{path\optional{, mode}} |
| 457 | Create a directory named \var{path} with numeric mode \var{mode}. |
| 458 | The default \var{mode} is \code{0777} (octal). On some systems, |
| 459 | \var{mode} is ignored. Where it is used, the current umask value is |
| 460 | first masked out. |
| 461 | Availability: Macintosh, \UNIX{}, Windows. |
| 462 | \end{funcdesc} |
| 463 | |
| 464 | \begin{funcdesc}{makedirs}{path\optional{, mode}} |
| 465 | \index{directory!creating} |
| 466 | Recursive directory creation function. Like \function{mkdir()}, |
| 467 | but makes all intermediate-level directories needed to contain the |
| 468 | leaf directory. Throws an \exception{error} exception if the leaf |
| 469 | directory already exists or cannot be created. The default \var{mode} |
| 470 | is \code{0777} (octal). |
| 471 | \versionadded{1.5.2} |
| 472 | \end{funcdesc} |
| 473 | |
| 474 | \begin{funcdesc}{readlink}{path} |
| 475 | Return a string representing the path to which the symbolic link |
| 476 | points. |
| 477 | Availability: \UNIX{}. |
| 478 | \end{funcdesc} |
| 479 | |
| 480 | \begin{funcdesc}{remove}{path} |
| 481 | Remove the file \var{path}. See \function{rmdir()} below to remove a |
| 482 | directory. This is identical to the \function{unlink()} function |
| 483 | documented below. |
| 484 | Availability: Macintosh, \UNIX{}, Windows. |
| 485 | \end{funcdesc} |
| 486 | |
| 487 | \begin{funcdesc}{removedirs}{path} |
| 488 | \index{directory!deleting} |
| 489 | Recursive directory removal function. Works like |
| 490 | \function{rmdir()} except that, if the leaf directory is |
| 491 | successfully removed, directories corresponding to rightmost path |
| 492 | segments will be pruned way until either the whole path is consumed or |
| 493 | an error is raised (which is ignored, because it generally means that |
| 494 | a parent directory is not empty). Throws an \exception{error} |
| 495 | exception if the leaf directory could not be successfully removed. |
| 496 | \versionadded{1.5.2} |
| 497 | \end{funcdesc} |
| 498 | |
| 499 | \begin{funcdesc}{rename}{src, dst} |
| 500 | Rename the file or directory \var{src} to \var{dst}. |
| 501 | Availability: Macintosh, \UNIX{}, Windows. |
| 502 | \end{funcdesc} |
| 503 | |
| 504 | \begin{funcdesc}{renames}{old, new} |
| 505 | Recursive directory or file renaming function. |
| 506 | Works like \function{rename()}, except creation of any intermediate |
| 507 | directories needed to make the new pathname good is attempted first. |
| 508 | After the rename, directories corresponding to rightmost path segments |
| 509 | of the old name will be pruned away using \function{removedirs()}. |
| 510 | |
| 511 | Note: this function can fail with the new directory structure made if |
| 512 | you lack permissions needed to remove the leaf directory or file. |
| 513 | \versionadded{1.5.2} |
| 514 | \end{funcdesc} |
| 515 | |
| 516 | \begin{funcdesc}{rmdir}{path} |
| 517 | Remove the directory \var{path}. |
| 518 | Availability: Macintosh, \UNIX{}, Windows. |
| 519 | \end{funcdesc} |
| 520 | |
| 521 | \begin{funcdesc}{stat}{path} |
| 522 | Perform a \cfunction{stat()} system call on the given path. The |
| 523 | return value is a tuple of at least 10 integers giving the most |
| 524 | important (and portable) members of the \emph{stat} structure, in the |
| 525 | order |
| 526 | \code{st_mode}, |
| 527 | \code{st_ino}, |
| 528 | \code{st_dev}, |
| 529 | \code{st_nlink}, |
| 530 | \code{st_uid}, |
| 531 | \code{st_gid}, |
| 532 | \code{st_size}, |
| 533 | \code{st_atime}, |
| 534 | \code{st_mtime}, |
| 535 | \code{st_ctime}. |
| 536 | More items may be added at the end by some implementations. |
| 537 | (On MS Windows, some items are filled with dummy values.) |
| 538 | Availability: Macintosh, \UNIX{}, Windows. |
| 539 | |
| 540 | Note: The standard module \refmodule{stat}\refstmodindex{stat} defines |
| 541 | functions and constants that are useful for extracting information |
| 542 | from a \ctype{stat} structure. |
| 543 | \end{funcdesc} |
| 544 | |
| 545 | \begin{funcdesc}{statvfs}{path} |
| 546 | Perform a \cfunction{statvfs()} system call on the given path. The |
Guido van Rossum | 0c9608c | 1999-02-03 16:32:37 +0000 | [diff] [blame] | 547 | return value is a tuple of 10 integers giving the most common |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 548 | members of the \ctype{statvfs} structure, in the order |
| 549 | \code{f_bsize}, |
| 550 | \code{f_frsize}, |
| 551 | \code{f_blocks}, |
| 552 | \code{f_bfree}, |
| 553 | \code{f_bavail}, |
| 554 | \code{f_files}, |
| 555 | \code{f_ffree}, |
| 556 | \code{f_favail}, |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 557 | \code{f_flag}, |
| 558 | \code{f_namemax}. |
| 559 | Availability: \UNIX{}. |
| 560 | |
| 561 | Note: The standard module \module{statvfs}\refstmodindex{statvfs} |
| 562 | defines constants that are useful for extracting information |
| 563 | from a \ctype{statvfs} structure. |
| 564 | \end{funcdesc} |
| 565 | |
| 566 | \begin{funcdesc}{symlink}{src, dst} |
| 567 | Create a symbolic link pointing to \var{src} named \var{dst}. |
| 568 | Availability: \UNIX{}. |
| 569 | \end{funcdesc} |
| 570 | |
| 571 | \begin{funcdesc}{unlink}{path} |
| 572 | Remove the file \var{path}. This is the same function as |
| 573 | \function{remove()}; the \function{unlink()} name is its traditional |
| 574 | \UNIX{} name. |
| 575 | Availability: Macintosh, \UNIX{}, Windows. |
| 576 | \end{funcdesc} |
| 577 | |
| 578 | \begin{funcdesc}{utime}{path, (atime, mtime)} |
| 579 | Set the access and modified time of the file to the given values. |
| 580 | (The second argument is a tuple of two items.) |
| 581 | Availability: Macintosh, \UNIX{}, Windows. |
| 582 | \end{funcdesc} |
| 583 | |
| 584 | |
| 585 | \subsection{Process Management \label{os-process}} |
| 586 | |
| 587 | These functions may be used to create and manage additional |
| 588 | processes. |
| 589 | |
| 590 | |
| 591 | \begin{funcdesc}{execl}{path, arg0, arg1, ...} |
| 592 | This is equivalent to |
| 593 | \samp{execv(\var{path}, (\var{arg0}, \var{arg1}, ...))}. |
| 594 | Availability: \UNIX{}, Windows. |
| 595 | \end{funcdesc} |
| 596 | |
| 597 | \begin{funcdesc}{execle}{path, arg0, arg1, ..., env} |
| 598 | This is equivalent to |
| 599 | \samp{execve(\var{path}, (\var{arg0}, \var{arg1}, ...), \var{env})}. |
| 600 | Availability: \UNIX{}, Windows. |
| 601 | \end{funcdesc} |
| 602 | |
| 603 | \begin{funcdesc}{execlp}{path, arg0, arg1, ...} |
| 604 | This is equivalent to |
| 605 | \samp{execvp(\var{path}, (\var{arg0}, \var{arg1}, ...))}. |
| 606 | Availability: \UNIX{}, Windows. |
| 607 | \end{funcdesc} |
| 608 | |
| 609 | \begin{funcdesc}{execv}{path, args} |
| 610 | Execute the executable \var{path} with argument list \var{args}, |
| 611 | replacing the current process (i.e., the Python interpreter). |
| 612 | The argument list may be a tuple or list of strings. |
| 613 | Availability: \UNIX{}, Windows. |
| 614 | \end{funcdesc} |
| 615 | |
| 616 | \begin{funcdesc}{execve}{path, args, env} |
| 617 | Execute the executable \var{path} with argument list \var{args}, |
| 618 | and environment \var{env}, |
| 619 | replacing the current process (i.e., the Python interpreter). |
| 620 | The argument list may be a tuple or list of strings. |
| 621 | The environment must be a dictionary mapping strings to strings. |
| 622 | Availability: \UNIX{}, Windows. |
| 623 | \end{funcdesc} |
| 624 | |
| 625 | \begin{funcdesc}{execvp}{path, args} |
| 626 | This is like \samp{execv(\var{path}, \var{args})} but duplicates |
| 627 | the shell's actions in searching for an executable file in a list of |
| 628 | directories. The directory list is obtained from |
| 629 | \code{environ['PATH']}. |
| 630 | Availability: \UNIX{}, Windows. |
| 631 | \end{funcdesc} |
| 632 | |
| 633 | \begin{funcdesc}{execvpe}{path, args, env} |
| 634 | This is a cross between \function{execve()} and \function{execvp()}. |
| 635 | The directory list is obtained from \code{\var{env}['PATH']}. |
| 636 | Availability: \UNIX{}, Windows. |
| 637 | \end{funcdesc} |
| 638 | |
| 639 | \begin{funcdesc}{_exit}{n} |
| 640 | Exit to the system with status \var{n}, without calling cleanup |
| 641 | handlers, flushing stdio buffers, etc. |
| 642 | Availability: \UNIX{}, Windows. |
| 643 | |
| 644 | Note: the standard way to exit is \code{sys.exit(\var{n})}. |
| 645 | \function{_exit()} should normally only be used in the child process |
| 646 | after a \function{fork()}. |
| 647 | \end{funcdesc} |
| 648 | |
| 649 | \begin{funcdesc}{fork}{} |
| 650 | Fork a child process. Return \code{0} in the child, the child's |
| 651 | process id in the parent. |
| 652 | Availability: \UNIX{}. |
| 653 | \end{funcdesc} |
| 654 | |
| 655 | \begin{funcdesc}{kill}{pid, sig} |
| 656 | \index{process!killing} |
| 657 | \index{process!signalling} |
| 658 | Kill the process \var{pid} with signal \var{sig}. |
| 659 | Availability: \UNIX{}. |
| 660 | \end{funcdesc} |
| 661 | |
| 662 | \begin{funcdesc}{nice}{increment} |
| 663 | Add \var{increment} to the process's ``niceness''. Return the new |
| 664 | niceness. |
| 665 | Availability: \UNIX{}. |
| 666 | \end{funcdesc} |
| 667 | |
| 668 | \begin{funcdesc}{plock}{op} |
| 669 | Lock program segments into memory. The value of \var{op} |
| 670 | (defined in \code{<sys/lock.h>}) determines which segments are locked. |
Fred Drake | 3906363 | 1999-02-26 14:05:02 +0000 | [diff] [blame] | 671 | Availability: \UNIX{}. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 672 | \end{funcdesc} |
| 673 | |
| 674 | \begin{funcdesc}{spawnv}{mode, path, args} |
| 675 | Execute the program \var{path} in a new process, passing the arguments |
| 676 | specified in \var{args} as command-line parameters. \var{args} may be |
| 677 | a list or a tuple. \var{mode} is a magic operational constant. See |
| 678 | the Visual \Cpp{} Runtime Library documentation for further |
Fred Drake | 2270208 | 1999-07-02 14:01:03 +0000 | [diff] [blame^] | 679 | information; the constants are exposed to the Python programmer as |
| 680 | listed below. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 681 | Availability: Windows. |
| 682 | \versionadded{1.5.2} |
| 683 | \end{funcdesc} |
| 684 | |
| 685 | \begin{funcdesc}{spawnve}{mode, path, args, env} |
| 686 | Execute the program \var{path} in a new process, passing the arguments |
| 687 | specified in \var{args} as command-line parameters and the contents of |
| 688 | the mapping \var{env} as the environment. \var{args} may be a list or |
| 689 | a tuple. \var{mode} is a magic operational constant. See the Visual |
Fred Drake | 2270208 | 1999-07-02 14:01:03 +0000 | [diff] [blame^] | 690 | \Cpp{} Runtime Library documentation for further information; the |
| 691 | constants are exposed to the Python programmer as listed below. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 692 | Availability: Windows. |
| 693 | \versionadded{1.5.2} |
| 694 | \end{funcdesc} |
| 695 | |
Fred Drake | 9329e5e | 1999-02-16 19:40:19 +0000 | [diff] [blame] | 696 | \begin{datadesc}{P_WAIT} |
| 697 | \dataline{P_NOWAIT} |
| 698 | \dataline{P_NOWAITO} |
| 699 | \dataline{P_OVERLAY} |
| 700 | \dataline{P_DETACH} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 701 | Possible values for the \var{mode} parameter to \function{spawnv()} |
| 702 | and \function{spawnve()}. |
| 703 | Availability: Windows. |
| 704 | \versionadded{1.5.2} |
| 705 | \end{datadesc} |
| 706 | |
| 707 | \begin{funcdesc}{system}{command} |
| 708 | Execute the command (a string) in a subshell. This is implemented by |
| 709 | calling the Standard C function \cfunction{system()}, and has the |
Fred Drake | ec6baaf | 1999-04-21 18:13:31 +0000 | [diff] [blame] | 710 | same limitations. Changes to \code{posix.environ}, \code{sys.stdin}, |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 711 | etc.\ are not reflected in the environment of the executed command. |
| 712 | The return value is the exit status of the process encoded in the |
Fred Drake | 7a62128 | 1999-06-10 15:07:05 +0000 | [diff] [blame] | 713 | format specified for \function{wait()}, except on Windows 95 and 98, |
Fred Drake | a88ef00 | 1999-06-18 19:11:25 +0000 | [diff] [blame] | 714 | where it is always \code{0}. Note that \POSIX{} does not specify the |
| 715 | meaning of the return value of the C \cfunction{system()} function, |
| 716 | so the return value of the Python function is system-dependent. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 717 | Availability: \UNIX{}, Windows. |
| 718 | \end{funcdesc} |
| 719 | |
| 720 | \begin{funcdesc}{times}{} |
| 721 | Return a 5-tuple of floating point numbers indicating accumulated (CPU |
| 722 | or other) |
| 723 | times, in seconds. The items are: user time, system time, children's |
| 724 | user time, children's system time, and elapsed real time since a fixed |
Fred Drake | ec6baaf | 1999-04-21 18:13:31 +0000 | [diff] [blame] | 725 | point in the past, in that order. See the \UNIX{} manual page |
| 726 | \manpage{times}{2} or the corresponding Windows Platform API |
| 727 | documentation. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 728 | Availability: \UNIX{}, Windows. |
| 729 | \end{funcdesc} |
| 730 | |
| 731 | \begin{funcdesc}{wait}{} |
| 732 | Wait for completion of a child process, and return a tuple containing |
| 733 | its pid and exit status indication: a 16-bit number, whose low byte is |
| 734 | the signal number that killed the process, and whose high byte is the |
| 735 | exit status (if the signal number is zero); the high bit of the low |
| 736 | byte is set if a core file was produced. |
| 737 | Availability: \UNIX{}. |
| 738 | \end{funcdesc} |
| 739 | |
| 740 | \begin{funcdesc}{waitpid}{pid, options} |
Fred Drake | 6b330ba8 | 1999-05-25 13:42:26 +0000 | [diff] [blame] | 741 | Wait for completion of a child process given by process id, and return |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 742 | a tuple containing its process id and exit status indication (encoded |
| 743 | as for \function{wait()}). The semantics of the call are affected by |
| 744 | the value of the integer \var{options}, which should be \code{0} for |
| 745 | normal operation. |
| 746 | Availability: \UNIX{}. |
| 747 | \end{funcdesc} |
| 748 | |
| 749 | \begin{datadesc}{WNOHANG} |
| 750 | The option for \function{waitpid()} to avoid hanging if no child |
| 751 | process status is available immediately. |
| 752 | Availability: \UNIX{}. |
| 753 | \end{datadesc} |
| 754 | |
| 755 | The following functions take a process stats code as returned by |
| 756 | \function{waitpid()} as a parameter. They may be used to determine |
| 757 | the disposition of a process. |
| 758 | |
| 759 | \begin{funcdesc}{WIFSTOPPED}{status} |
| 760 | Return true if the process has been stopped. |
| 761 | Availability: \UNIX{}. |
| 762 | \end{funcdesc} |
| 763 | |
| 764 | \begin{funcdesc}{WIFSIGNALED}{status} |
| 765 | Return true if the process exited due to a signal. |
| 766 | Availability: \UNIX{}. |
| 767 | \end{funcdesc} |
| 768 | |
| 769 | \begin{funcdesc}{WIFEXITED}{status} |
| 770 | Return true if the process exited using the \manpage{exit}{2} system |
| 771 | call. |
| 772 | Availability: \UNIX{}. |
| 773 | \end{funcdesc} |
| 774 | |
| 775 | \begin{funcdesc}{WEXITSTATUS}{status} |
| 776 | If \code{WIFEXITED(\var{status})} is true, return the integer |
| 777 | parameter to the \manpage{exit}{2} system call. Otherwise, the return |
| 778 | value is meaningless. |
| 779 | Availability: \UNIX{}. |
| 780 | \end{funcdesc} |
| 781 | |
| 782 | \begin{funcdesc}{WSTOPSIG}{status} |
Fred Drake | 35c3ffd | 1999-03-04 14:08:10 +0000 | [diff] [blame] | 783 | Return the signal which caused the process to stop. |
| 784 | Availability: \UNIX{}. |
| 785 | \end{funcdesc} |
| 786 | |
| 787 | \begin{funcdesc}{WTERMSIG}{status} |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 788 | Return the signal which caused the process to exit. |
| 789 | Availability: \UNIX{}. |
| 790 | \end{funcdesc} |
| 791 | |
| 792 | |
| 793 | \subsection{Miscellanenous System Data \label{os-path}} |
| 794 | |
| 795 | The follow data values are used to support path manipulation |
| 796 | operations. These are defined for all platforms. |
| 797 | |
| 798 | Higher-level operations on pathnames are defined in the |
| 799 | \refmodule{os.path} module. |
| 800 | |
| 801 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 802 | \begin{datadesc}{curdir} |
| 803 | The constant string used by the OS to refer to the current directory, |
Fred Drake | 1a3c2a0 | 1998-08-06 15:18:23 +0000 | [diff] [blame] | 804 | e.g.\ \code{'.'} for \POSIX{} or \code{':'} for the Macintosh. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 805 | \end{datadesc} |
| 806 | |
| 807 | \begin{datadesc}{pardir} |
| 808 | The constant string used by the OS to refer to the parent directory, |
Fred Drake | 1a3c2a0 | 1998-08-06 15:18:23 +0000 | [diff] [blame] | 809 | e.g.\ \code{'..'} for \POSIX{} or \code{'::'} for the Macintosh. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 810 | \end{datadesc} |
| 811 | |
| 812 | \begin{datadesc}{sep} |
Guido van Rossum | b2afc81 | 1997-08-29 22:37:44 +0000 | [diff] [blame] | 813 | The character used by the OS to separate pathname components, |
Fred Drake | 1a3c2a0 | 1998-08-06 15:18:23 +0000 | [diff] [blame] | 814 | e.g.\ \character{/} for \POSIX{} or \character{:} for the Macintosh. |
| 815 | Note that knowing this is not sufficient to be able to parse or |
| 816 | concatenate pathnames --- use \function{os.path.split()} and |
| 817 | \function{os.path.join()} --- but it is occasionally useful. |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 818 | \end{datadesc} |
| 819 | |
Guido van Rossum | b2afc81 | 1997-08-29 22:37:44 +0000 | [diff] [blame] | 820 | \begin{datadesc}{altsep} |
| 821 | An alternative character used by the OS to separate pathname components, |
| 822 | or \code{None} if only one separator character exists. This is set to |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 823 | \character{/} on DOS and Windows systems where \code{sep} is a backslash. |
Guido van Rossum | b2afc81 | 1997-08-29 22:37:44 +0000 | [diff] [blame] | 824 | \end{datadesc} |
| 825 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 826 | \begin{datadesc}{pathsep} |
| 827 | The character conventionally used by the OS to separate search patch |
Fred Drake | 1a3c2a0 | 1998-08-06 15:18:23 +0000 | [diff] [blame] | 828 | components (as in \envvar{PATH}), e.g.\ \character{:} for \POSIX{} or |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 829 | \character{;} for DOS and Windows. |
Guido van Rossum | 9c59ce9 | 1998-06-30 15:54:27 +0000 | [diff] [blame] | 830 | \end{datadesc} |
| 831 | |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 832 | \begin{datadesc}{defpath} |
Fred Drake | 1a3c2a0 | 1998-08-06 15:18:23 +0000 | [diff] [blame] | 833 | The default search path used by \function{exec*p*()} if the environment |
Guido van Rossum | 470be14 | 1995-03-17 16:07:09 +0000 | [diff] [blame] | 834 | doesn't have a \code{'PATH'} key. |
| 835 | \end{datadesc} |
| 836 | |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 837 | \begin{datadesc}{linesep} |
| 838 | The string used to separate (or, rather, terminate) lines on the |
Fred Drake | ec6baaf | 1999-04-21 18:13:31 +0000 | [diff] [blame] | 839 | current platform. This may be a single character, |
| 840 | e.g.\ \code{'\e n'} for \POSIX{} or \code{'\e r'} for MacOS, or multiple |
| 841 | characters, e.g.\ \code{'\e r\e n'} for MS-DOS and MS Windows. |
Fred Drake | 215fe2f | 1999-02-02 19:02:35 +0000 | [diff] [blame] | 842 | \end{datadesc} |