Portable way to refer to the null device?

skip at pobox.com skip at pobox.com
Sat Feb 7 04:51:13 CET 2009


    Roy> I need to run a command using subprocess.Popen() and have stdin
    Roy> connected to the null device. 

os.path.devnull should do what you want:

    >>> os.path.devnull
    '/dev/null'
    >>> import ntpath
    >>> ntpath.devnull
    'nul'

-- 
Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/



More information about the Python-list mailing list