n'} for \POSIX{} or \code{'\e r'} for Mac OS, or multiple characters,
for example, \code{'\e r\e n'} for Windows.
\end{datadesc}
+
+\begin{datadesc}{devnull}
+The file path of the null device.
+For example: \code{'/dev/null'} for \POSIX{} or \code{'Dev:Nul'} for the
+Macintosh.
+Also available via \module{os.path}.
+\versionadded{2.4}
+\end{datadesc}
"getatime","getctime", "islink","exists","isdir","isfile",
"walk","expanduser","expandvars","normpath","abspath",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
- "realpath","supports_unicode_filenames"]
+ "devnull","realpath","supports_unicode_filenames"]
# strings representing various path-related bits and pieces
curdir = ':'
pathsep = '\n'
defpath = ':'
altsep = None
+devnull = 'Dev:Null'
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
"getatime","getctime", "islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath","splitunc",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
- "realpath","supports_unicode_filenames"]
+ "devnull","realpath","supports_unicode_filenames"]
# strings representing various path-related bits and pieces
curdir = '.'
elif 'os2' in sys.builtin_module_names:
# OS/2 w/ VACPP
altsep = '/'
+devnull = 'nul'
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
- os.pathsep is the component separator used in $PATH etc
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
- os.defpath is the default search path for executables
+ - os.devnull is the file path of the null device ('/dev/null', etc.)
Programs that import and use 'os' stand a better chance of being
portable between different platforms. Of course, they must then
# Note: more names are added to __all__ later.
__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
- "defpath", "name", "path"]
+ "defpath", "name", "path", "devnull"]
def _get_exports_list(module):
try:
raise ImportError, 'no os specific module found'
sys.modules['os.path'] = path
-from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep
+from os.path import curdir, pardir, sep, pathsep, defpath, extsep, altsep, \
+ devnull
del _names
"getatime","getctime", "islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath","splitunc",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
- "realpath","supports_unicode_filenames"]
+ "devnull","realpath","supports_unicode_filenames"]
# strings representing various path-related bits and pieces
curdir = '.'
altsep = '\\'
pathsep = ';'
defpath = '.;C:\\bin'
+devnull = 'nul'
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
"walk","expanduser","expandvars","normpath","abspath",
"samefile","sameopenfile","samestat",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
- "realpath","supports_unicode_filenames"]
+ "devnull","realpath","supports_unicode_filenames"]
# strings representing various path-related bits and pieces
curdir = '.'
pathsep = ':'
defpath = ':/bin:/usr/bin'
altsep = None
+devnull = '/dev/null'
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
os.removedirs(path)
+class DevNullTests (unittest.TestCase):
+ def test_devnull(self):
+ f = file(os.devnull, 'w')
+ f.write('hello')
+ f.close()
+ f = file(os.devnull, 'r')
+ assert f.read() == ''
+ f.close()
def test_main():
test_support.run_unittest(
EnvironTests,
WalkTests,
MakedirTests,
+ DevNullTests,
)
if __name__ == "__main__":
Library
-------
+- os.path.devnull has been added for all supported platforms.
+
- Fixed #877165: distutils now picks the right C++ compiler command
on cygwin and mingw32.