27
If not separately noted, all functions that claim "Availability: Unix" are
28
supported on Mac OS X, which builds on a Unix core.
27
32
All functions in this module raise :exc:`OSError` in the case of invalid or
28
33
inaccessible file names and paths, or other arguments that have the correct
29
34
type, but are not accepted by the operating system.
46
51
The corresponding operating system dependent standard module for pathname
47
operations, such as :mod:`posixpath` or :mod:`macpath`. Thus, given the proper
52
operations, such as :mod:`posixpath` or :mod:`ntpath`. Thus, given the proper
48
53
imports, ``os.path.split(file)`` is equivalent to but more portable than
49
54
``posixpath.split(file)``. Note that this is also an importable module: it may
50
55
be imported directly as :mod:`os.path`.
84
On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may cause
85
memory leaks. Refer to the system documentation for :cfunc:`putenv`.
89
On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may
90
cause memory leaks. Refer to the system documentation for
87
93
If :func:`putenv` is not provided, a modified copy of this mapping may be
88
94
passed to the appropriate process-creation functions to cause child processes
205
On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may cause
206
memory leaks. Refer to the system documentation for putenv.
211
On some platforms, including FreeBSD and Mac OS X, setting ``environ`` may
212
cause memory leaks. Refer to the system documentation for putenv.
208
214
When :func:`putenv` is supported, assignments to items in ``os.environ`` are
209
215
automatically translated into corresponding calls to :func:`putenv`; however,
339
345
Return an open file object connected to the file descriptor *fd*. The *mode*
340
346
and *bufsize* arguments have the same meaning as the corresponding arguments to
341
the built-in :func:`open` function. Availability: Macintosh, Unix, Windows.
347
the built-in :func:`open` function. Availability: Unix, Windows.
343
349
.. versionchanged:: 2.3
344
350
When specified, the *mode* argument must now start with one of the letters
359
365
status of the command (encoded in the format specified for :func:`wait`) is
360
366
available as the return value of the :meth:`close` method of the file object,
361
367
except that when the exit status is zero (termination without errors), ``None``
362
is returned. Availability: Macintosh, Unix, Windows.
368
is returned. Availability: Unix, Windows.
364
370
.. deprecated:: 2.6
365
This function is obsolete. Use the :mod:`subprocess` module.
371
This function is obsolete. Use the :mod:`subprocess` module. Check
372
especially the :ref:`subprocess-replacements` section.
367
374
.. versionchanged:: 2.0
368
375
This function worked unreliably under Windows in earlier versions of Python.
376
383
Return a new file object opened in update mode (``w+b``). The file has no
377
384
directory entries associated with it and will be automatically deleted once
378
there are no file descriptors for the file. Availability: Macintosh, Unix,
385
there are no file descriptors for the file. Availability: Unix,
381
388
There are a number of different :func:`popen\*` functions that provide slightly
413
420
.. deprecated:: 2.6
414
All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
421
This function is obsolete. Use the :mod:`subprocess` module. Check
422
especially the :ref:`subprocess-replacements` section.
417
Availability: Macintosh, Unix, Windows.
424
Availability: Unix, Windows.
419
426
.. versionadded:: 2.0
425
432
child_stdout, child_stderr)``.
427
434
.. deprecated:: 2.6
428
All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
435
This function is obsolete. Use the :mod:`subprocess` module. Check
436
especially the :ref:`subprocess-replacements` section.
431
Availability: Macintosh, Unix, Windows.
438
Availability: Unix, Windows.
433
440
.. versionadded:: 2.0
439
446
child_stdout_and_stderr)``.
441
448
.. deprecated:: 2.6
442
All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
449
This function is obsolete. Use the :mod:`subprocess` module. Check
450
especially the :ref:`subprocess-replacements` section.
445
Availability: Macintosh, Unix, Windows.
452
Availability: Unix, Windows.
447
454
.. versionadded:: 2.0
485
492
.. function:: closerange(fd_low, fd_high)
487
494
Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive),
488
ignoring errors. Availability: Macintosh, Unix, Windows. Equivalent to::
495
ignoring errors. Availability: Unix, Windows. Equivalent to::
490
497
for fd in xrange(fd_low, fd_high):
499
506
.. function:: dup(fd)
501
Return a duplicate of file descriptor *fd*. Availability: Macintosh, Unix,
508
Return a duplicate of file descriptor *fd*. Availability: Unix,
505
512
.. function:: dup2(fd, fd2)
507
514
Duplicate file descriptor *fd* to *fd2*, closing the latter first if necessary.
508
Availability: Macintosh, Unix, Windows.
515
Availability: Unix, Windows.
511
518
.. function:: fchmod(fd, mode)
540
547
additional names as well. The names known to the host operating system are
541
548
given in the ``pathconf_names`` dictionary. For configuration variables not
542
549
included in that mapping, passing an integer for *name* is also accepted.
543
Availability: Macintosh, Unix.
545
552
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
546
553
specific value for *name* is not supported by the host system, even if it is
568
575
If you're starting with a Python file object *f*, first do ``f.flush()``, and
569
576
then do ``os.fsync(f.fileno())``, to ensure that all internal buffers associated
570
with *f* are written to disk. Availability: Macintosh, Unix, and Windows
577
with *f* are written to disk. Availability: Unix, and Windows
571
578
starting in 2.2.3.
574
581
.. function:: ftruncate(fd, length)
576
583
Truncate the file corresponding to file descriptor *fd*, so that it is at most
577
*length* bytes in size. Availability: Macintosh, Unix.
584
*length* bytes in size. Availability: Unix.
580
587
.. function:: isatty(fd)
582
589
Return ``True`` if the file descriptor *fd* is open and connected to a
583
tty(-like) device, else ``False``. Availability: Macintosh, Unix.
590
tty(-like) device, else ``False``. Availability: Unix.
586
593
.. function:: lseek(fd, pos, how)
589
596
by *how*: :const:`SEEK_SET` or ``0`` to set the position relative to the
590
597
beginning of the file; :const:`SEEK_CUR` or ``1`` to set it relative to the
591
598
current position; :const:`os.SEEK_END` or ``2`` to set it relative to the end of
592
the file. Availability: Macintosh, Unix, Windows.
599
the file. Availability: Unix, Windows.
595
602
.. function:: open(file, flags[, mode])
597
604
Open the file *file* and set various flags according to *flags* and possibly its
598
605
mode according to *mode*. The default *mode* is ``0777`` (octal), and the
599
606
current umask value is first masked out. Return the file descriptor for the
600
newly opened file. Availability: Macintosh, Unix, Windows.
607
newly opened file. Availability: Unix, Windows.
602
609
For a description of the flag and mode values, see the C run-time documentation;
603
610
flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
618
625
Open a new pseudo-terminal pair. Return a pair of file descriptors ``(master,
619
626
slave)`` for the pty and the tty, respectively. For a (slightly) more portable
620
approach, use the :mod:`pty` module. Availability: Macintosh, some flavors of
627
approach, use the :mod:`pty` module. Availability: some flavors of
624
631
.. function:: pipe()
626
633
Create a pipe. Return a pair of file descriptors ``(r, w)`` usable for reading
627
and writing, respectively. Availability: Macintosh, Unix, Windows.
634
and writing, respectively. Availability: Unix, Windows.
630
637
.. function:: read(fd, n)
632
639
Read at most *n* bytes from file descriptor *fd*. Return a string containing the
633
640
bytes read. If the end of the file referred to by *fd* has been reached, an
634
empty string is returned. Availability: Macintosh, Unix, Windows.
641
empty string is returned. Availability: Unix, Windows.
645
652
.. function:: tcgetpgrp(fd)
647
654
Return the process group associated with the terminal given by *fd* (an open
648
file descriptor as returned by :func:`open`). Availability: Macintosh, Unix.
655
file descriptor as returned by :func:`open`). Availability: Unix.
651
658
.. function:: tcsetpgrp(fd, pg)
653
660
Set the process group associated with the terminal given by *fd* (an open file
654
descriptor as returned by :func:`open`) to *pg*. Availability: Macintosh, Unix.
661
descriptor as returned by :func:`open`) to *pg*. Availability: Unix.
657
664
.. function:: ttyname(fd)
659
666
Return a string which specifies the terminal device associated with
660
667
file descriptor *fd*. If *fd* is not associated with a terminal device, an
661
exception is raised. Availability:Macintosh, Unix.
668
exception is raised. Availability: Unix.
664
671
.. function:: write(fd, str)
666
673
Write the string *str* to file descriptor *fd*. Return the number of bytes
667
actually written. Availability: Macintosh, Unix, Windows.
674
actually written. Availability: Unix, Windows.
734
741
Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
735
respectively. Availability: Windows, Macintosh, Unix.
742
respectively. Availability: Windows, Unix.
737
744
.. versionadded:: 2.5
751
758
can be the inclusive OR of one or more of :const:`R_OK`, :const:`W_OK`, and
752
759
:const:`X_OK` to test permissions. Return :const:`True` if access is allowed,
753
760
:const:`False` if not. See the Unix man page :manpage:`access(2)` for more
754
information. Availability: Macintosh, Unix, Windows.
761
information. Availability: Unix, Windows.
811
818
.. function:: getcwd()
813
820
Return a string representing the current working directory. Availability:
814
Macintosh, Unix, Windows.
817
824
.. function:: getcwdu()
819
826
Return a Unicode object representing the current working directory.
820
Availability: Macintosh, Unix, Windows.
827
Availability: Unix, Windows.
822
829
.. versionadded:: 2.3
891
898
.. function:: chown(path, uid, gid)
893
900
Change the owner and group id of *path* to the numeric *uid* and *gid*. To leave
894
one of the ids unchanged, set it to -1. Availability: Macintosh, Unix.
901
one of the ids unchanged, set it to -1. Availability: Unix.
897
904
.. function:: lchflags(path, flags)
914
921
.. function:: lchown(path, uid, gid)
916
923
Change the owner and group id of *path* to the numeric *uid* and *gid*. This
917
function will not follow symbolic links. Availability: Macintosh, Unix.
924
function will not follow symbolic links. Availability: Unix.
919
926
.. versionadded:: 2.3
922
929
.. function:: link(src, dst)
924
Create a hard link pointing to *src* named *dst*. Availability: Macintosh, Unix.
931
Create a hard link pointing to *src* named *dst*. Availability: Unix.
927
934
.. function:: listdir(path)
929
936
Return a list containing the names of the entries in the directory. The list is
930
937
in arbitrary order. It does not include the special entries ``'.'`` and
931
``'..'`` even if they are present in the directory. Availability: Macintosh,
938
``'..'`` even if they are present in the directory. Availability:
934
941
.. versionchanged:: 2.3
948
955
Create a FIFO (a named pipe) named *path* with numeric mode *mode*. The default
949
956
*mode* is ``0666`` (octal). The current umask value is first masked out from
950
the mode. Availability: Macintosh, Unix.
957
the mode. Availability: Unix.
952
959
FIFOs are pipes that can be accessed like regular files. FIFOs exist until they
953
960
are deleted (for example with :func:`os.unlink`). Generally, FIFOs are used as
998
1005
Create a directory named *path* with numeric mode *mode*. The default *mode* is
999
1006
``0777`` (octal). On some systems, *mode* is ignored. Where it is used, the
1000
current umask value is first masked out. Availability: Macintosh, Unix, Windows.
1007
current umask value is first masked out. Availability: Unix, Windows.
1002
1009
It is also possible to create temporary directories; see the
1003
1010
:mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
1035
1042
additional names as well. The names known to the host operating system are
1036
1043
given in the ``pathconf_names`` dictionary. For configuration variables not
1037
1044
included in that mapping, passing an integer for *name* is also accepted.
1038
Availability: Macintosh, Unix.
1040
1047
If *name* is a string and is not known, :exc:`ValueError` is raised. If a
1041
1048
specific value for *name* is not supported by the host system, even if it is
1071
1078
:func:`unlink` function documented below. On Windows, attempting to remove a
1072
1079
file that is in use causes an exception to be raised; on Unix, the directory
1073
1080
entry is removed but the storage allocated to the file is not made available
1074
until the original file is no longer in use. Availability: Macintosh, Unix,
1081
until the original file is no longer in use. Availability: Unix,
1100
1107
the renaming will be an atomic operation (this is a POSIX requirement). On
1101
1108
Windows, if *dst* already exists, :exc:`OSError` will be raised even if it is a
1102
1109
file; there may be no way to implement an atomic rename when *dst* names an
1103
existing file. Availability: Macintosh, Unix, Windows.
1110
existing file. Availability: Unix, Windows.
1106
1113
.. function:: renames(old, new)
1184
1191
:attr:`st_mtime` has 2-second resolution, and :attr:`st_atime` has only 1-day
1185
1192
resolution. See your operating system documentation for details.
1187
Availability: Macintosh, Unix, Windows.
1194
Availability: Unix, Windows.
1189
1196
.. versionchanged:: 2.2
1190
1197
Added access to values as attributes of the returned object.
1264
1271
Use of :func:`tempnam` is vulnerable to symlink attacks; consider using
1265
1272
:func:`tmpfile` (section :ref:`os-newstreams`) instead.
1267
Availability: Macintosh, Unix, Windows.
1274
Availability: Unix, Windows.
1270
1277
.. function:: tmpnam()
1296
1303
.. function:: unlink(path)
1298
1305
Remove the file *path*. This is the same function as :func:`remove`; the
1299
:func:`unlink` name is its traditional Unix name. Availability: Macintosh, Unix,
1306
:func:`unlink` name is its traditional Unix name. Availability: Unix,
1303
1310
.. function:: utime(path, times)
1305
Set the access and modified times of the file specified by *path*. If *times* is
1306
``None``, then the file's access and modified times are set to the current time.
1307
Otherwise, *times* must be a 2-tuple of numbers, of the form ``(atime, mtime)``
1308
which is used to set the access and modified times, respectively. Whether a
1309
directory can be given for *path* depends on whether the operating system
1310
implements directories as files (for example, Windows does not). Note that the
1311
exact times you set here may not be returned by a subsequent :func:`stat` call,
1312
depending on the resolution with which your operating system records access and
1313
modification times; see :func:`stat`.
1312
Set the access and modified times of the file specified by *path*. If *times*
1313
is ``None``, then the file's access and modified times are set to the current
1314
time. (The effect is similar to running the Unix program :program:`touch` on
1315
the path.) Otherwise, *times* must be a 2-tuple of numbers, of the form
1316
``(atime, mtime)`` which is used to set the access and modified times,
1317
respectively. Whether a directory can be given for *path* depends on whether
1318
the operating system implements directories as files (for example, Windows
1319
does not). Note that the exact times you set here may not be returned by a
1320
subsequent :func:`stat` call, depending on the resolution with which your
1321
operating system records access and modification times; see :func:`stat`.
1315
1323
.. versionchanged:: 2.0
1316
1324
Added support for ``None`` for *times*.
1318
Availability: Macintosh, Unix, Windows.
1326
Availability: Unix, Windows.
1321
1329
.. function:: walk(top[, topdown=True [, onerror=None[, followlinks=False]]])
1428
1436
behavior is to produce a core dump; on Windows, the process immediately returns
1429
1437
an exit code of ``3``. Be aware that programs which use :func:`signal.signal`
1430
1438
to register a handler for :const:`SIGABRT` will behave differently.
1431
Availability: Macintosh, Unix, Windows.
1439
Availability: Unix, Windows.
1434
1442
.. function:: execl(path, arg0, arg1, ...)
1469
1477
used to define the environment variables for the new process (these are used
1470
1478
instead of the current process' environment); the functions :func:`execl`,
1471
1479
:func:`execlp`, :func:`execv`, and :func:`execvp` all cause the new process to
1472
inherit the environment of the current process. Availability: Macintosh, Unix,
1480
inherit the environment of the current process. Availability: Unix,
1476
1484
.. function:: _exit(n)
1478
1486
Exit to the system with status *n*, without calling cleanup handlers, flushing
1479
stdio buffers, etc. Availability: Macintosh, Unix, Windows.
1487
stdio buffers, etc. Availability: Unix, Windows.
1504
1512
.. data:: EX_USAGE
1506
1514
Exit code that means the command was used incorrectly, such as when the wrong
1507
number of arguments are given. Availability: Macintosh, Unix.
1515
number of arguments are given. Availability: Unix.
1509
1517
.. versionadded:: 2.3
1512
1520
.. data:: EX_DATAERR
1514
Exit code that means the input data was incorrect. Availability: Macintosh,
1522
Exit code that means the input data was incorrect. Availability: Unix.
1517
1524
.. versionadded:: 2.3
1520
1527
.. data:: EX_NOINPUT
1522
1529
Exit code that means an input file did not exist or was not readable.
1523
Availability: Macintosh, Unix.
1525
1532
.. versionadded:: 2.3
1528
1535
.. data:: EX_NOUSER
1530
Exit code that means a specified user did not exist. Availability: Macintosh,
1537
Exit code that means a specified user did not exist. Availability: Unix.
1533
1539
.. versionadded:: 2.3
1536
1542
.. data:: EX_NOHOST
1538
Exit code that means a specified host did not exist. Availability: Macintosh,
1544
Exit code that means a specified host did not exist. Availability: Unix.
1541
1546
.. versionadded:: 2.3
1594
1599
Exit code that means a temporary failure occurred. This indicates something
1595
1600
that may not really be an error, such as a network connection that couldn't be
1596
made during a retryable operation. Availability: Macintosh, Unix.
1601
made during a retryable operation. Availability: Unix.
1598
1603
.. versionadded:: 2.3
1645
1649
new child's process id in the parent, and *fd* is the file descriptor of the
1646
1650
master end of the pseudo-terminal. For a more portable approach, use the
1647
1651
:mod:`pty` module. If an error occurs :exc:`OSError` is raised.
1648
Availability: Macintosh, some flavors of Unix.
1652
Availability: some flavors of Unix.
1651
1655
.. function:: kill(pid, sig)
1657
1661
Send signal *sig* to the process *pid*. Constants for the specific signals
1658
1662
available on the host platform are defined in the :mod:`signal` module.
1659
Availability: Macintosh, Unix.
1662
1666
.. function:: killpg(pgid, sig)
1674
1677
.. function:: nice(increment)
1676
1679
Add *increment* to the process's "niceness". Return the new niceness.
1677
Availability: Macintosh, Unix.
1680
1683
.. function:: plock(op)
1682
1685
Lock program segments into memory. The value of *op* (defined in
1683
``<sys/lock.h>``) determines which segments are locked. Availability: Macintosh,
1686
``<sys/lock.h>``) determines which segments are locked. Availability: Unix.
1687
1689
.. function:: popen(...)
1708
1710
(Note that the :mod:`subprocess` module provides more powerful facilities for
1709
1711
spawning new processes and retrieving their results; using that module is
1710
preferable to using these functions.)
1712
preferable to using these functions. Check specially the *Replacing Older
1713
Functions with the subprocess Module* section in that documentation page.)
1712
1715
If *mode* is :const:`P_NOWAIT`, this function returns the process id of the new
1713
1716
process; if *mode* is :const:`P_WAIT`, returns the process's exit code if it
1762
1765
Possible values for the *mode* parameter to the :func:`spawn\*` family of
1763
1766
functions. If either of these values is given, the :func:`spawn\*` functions
1764
1767
will return as soon as the new process has been created, with the process id as
1765
the return value. Availability: Macintosh, Unix, Windows.
1768
the return value. Availability: Unix, Windows.
1767
1770
.. versionadded:: 1.6
1773
1776
functions. If this is given as *mode*, the :func:`spawn\*` functions will not
1774
1777
return until the new process has run to completion and will return the exit code
1775
1778
of the process the run is successful, or ``-signal`` if a signal kills the
1776
process. Availability: Macintosh, Unix, Windows.
1779
process. Availability: Unix, Windows.
1778
1781
.. versionadded:: 1.6
1838
1841
the command run; on systems using a non-native shell, consult your shell
1841
Availability: Macintosh, Unix, Windows.
1844
Availability: Unix, Windows.
1843
1846
The :mod:`subprocess` module provides more powerful facilities for spawning new
1844
1847
processes and retrieving their results; using that module is preferable to using
1848
this function. Use the :mod:`subprocess` module. Check especially the
1849
:ref:`subprocess-replacements` section.
1848
1852
.. function:: times()
1851
1855
other) times, in seconds. The items are: user time, system time, children's
1852
1856
user time, children's system time, and elapsed real time since a fixed point in
1853
1857
the past, in that order. See the Unix manual page :manpage:`times(2)` or the
1854
corresponding Windows Platform API documentation. Availability: Macintosh, Unix,
1858
corresponding Windows Platform API documentation. Availability: Unix,
1855
1859
Windows. On Windows, only the first two items are filled, the others are zero.
1861
1865
and exit status indication: a 16-bit number, whose low byte is the signal number
1862
1866
that killed the process, and whose high byte is the exit status (if the signal
1863
1867
number is zero); the high bit of the low byte is set if a core file was
1864
produced. Availability: Macintosh, Unix.
1868
produced. Availability: Unix.
1867
1871
.. function:: waitpid(pid, options)
1880
1884
``-1``, status is requested for any process in the process group ``-pid`` (the
1881
1885
absolute value of *pid*).
1887
An :exc:`OSError` is raised with the value of errno when the syscall
1883
1890
On Windows: Wait for completion of a process given by process handle *pid*, and
1884
1891
return a tuple containing *pid*, and its exit status shifted left by 8 bits
1885
1892
(shifting makes cross-platform use of the function easier). A *pid* less than or
1944
1951
.. function:: WCOREDUMP(status)
1946
1953
Return ``True`` if a core dump was generated for the process, otherwise
1947
return ``False``. Availability: Macintosh, Unix.
1954
return ``False``. Availability: Unix.
1949
1956
.. versionadded:: 2.3
1966
1973
.. function:: WIFSIGNALED(status)
1968
1975
Return ``True`` if the process exited due to a signal, otherwise return
1969
``False``. Availability: Macintosh, Unix.
1976
``False``. Availability: Unix.
1972
1979
.. function:: WIFEXITED(status)
1974
1981
Return ``True`` if the process exited using the :manpage:`exit(2)` system call,
1975
otherwise return ``False``. Availability: Macintosh, Unix.
1982
otherwise return ``False``. Availability: Unix.
1978
1985
.. function:: WEXITSTATUS(status)
1980
1987
If ``WIFEXITED(status)`` is true, return the integer parameter to the
1981
1988
:manpage:`exit(2)` system call. Otherwise, the return value is meaningless.
1982
Availability: Macintosh, Unix.
1985
1992
.. function:: WSTOPSIG(status)
1987
Return the signal which caused the process to stop. Availability: Macintosh,
1994
Return the signal which caused the process to stop. Availability: Unix.
1991
1997
.. function:: WTERMSIG(status)
1993
Return the signal which caused the process to exit. Availability: Macintosh,
1999
Return the signal which caused the process to exit. Availability: Unix.
2009
2014
The names known to the host operating system are given as the keys of the
2010
2015
``confstr_names`` dictionary. For configuration variables not included in that
2011
2016
mapping, passing an integer for *name* is also accepted. Availability:
2014
2019
If the configuration value specified by *name* isn't defined, ``None`` is
2025
2030
Dictionary mapping names accepted by :func:`confstr` to the integer values
2026
2031
defined for those names by the host operating system. This can be used to
2027
determine the set of names known to the system. Availability: Macintosh, Unix.
2032
determine the set of names known to the system. Availability: Unix.
2030
2035
.. function:: getloadavg()
2042
2047
specified by *name* isn't defined, ``-1`` is returned. The comments regarding
2043
2048
the *name* parameter for :func:`confstr` apply here as well; the dictionary that
2044
2049
provides information on the known names is given by ``sysconf_names``.
2045
Availability: Macintosh, Unix.
2048
2053
.. data:: sysconf_names
2050
2055
Dictionary mapping names accepted by :func:`sysconf` to the integer values
2051
2056
defined for those names by the host operating system. This can be used to
2052
determine the set of names known to the system. Availability: Macintosh, Unix.
2057
determine the set of names known to the system. Availability: Unix.
2054
2059
The following data values are used to support path manipulation operations. These
2055
2060
are defined for all platforms.
2060
2065
.. data:: curdir
2062
2067
The constant string used by the operating system to refer to the current
2063
directory. For example: ``'.'`` for POSIX or ``':'`` for Mac OS 9. Also
2064
available via :mod:`os.path`.
2068
directory. This is ``'.'`` for Windows and POSIX. Also available via
2067
2072
.. data:: pardir
2069
2074
The constant string used by the operating system to refer to the parent
2070
directory. For example: ``'..'`` for POSIX or ``'::'`` for Mac OS 9. Also
2071
available via :mod:`os.path`.
2075
directory. This is ``'..'`` for Windows and POSIX. Also available via
2076
The character used by the operating system to separate pathname components, for
2077
example, ``'/'`` for POSIX or ``':'`` for Mac OS 9. Note that knowing this is
2078
not sufficient to be able to parse or concatenate pathnames --- use
2081
The character used by the operating system to separate pathname components.
2082
This is ``'/'`` for POSIX and ``'\\'`` for Windows. Note that knowing this
2083
is not sufficient to be able to parse or concatenate pathnames --- use
2079
2084
:func:`os.path.split` and :func:`os.path.join` --- but it is occasionally
2080
2085
useful. Also available via :mod:`os.path`.
2112
2117
.. data:: linesep
2114
2119
The string used to separate (or, rather, terminate) lines on the current
2115
platform. This may be a single character, such as ``'\n'`` for POSIX or
2116
``'\r'`` for Mac OS, or multiple characters, for example, ``'\r\n'`` for
2117
Windows. Do not use *os.linesep* as a line terminator when writing files opened
2118
in text mode (the default); use a single ``'\n'`` instead, on all platforms.
2120
platform. This may be a single character, such as ``'\n'`` for POSIX, or
2121
multiple characters, for example, ``'\r\n'`` for Windows. Do not use
2122
*os.linesep* as a line terminator when writing files opened in text mode (the
2123
default); use a single ``'\n'`` instead, on all platforms.
2121
2126
.. data:: devnull
2123
The file path of the null device. For example: ``'/dev/null'`` for POSIX or
2124
``'Dev:Nul'`` for Mac OS 9. Also available via :mod:`os.path`.
2128
The file path of the null device. For example: ``'/dev/null'`` for POSIX.
2129
Also available via :mod:`os.path`.
2126
2131
.. versionadded:: 2.4