Portable way to refer to the null device?

Roy Smith roy at panix.com
Sat Feb 7 04:32:20 CET 2009

I need to run a command using subprocess.Popen() and have stdin
connected to the null device.  On unix, I would do:

        self.process = subprocess.Popen(argv,
                                        stdout=open(outfile, 'w'),
                                        stderr=open(errfile, 'w'),

but that's not portable to windows.  Does Python have a portable way
to get a file object connected to the null device, regardless of what
operating system you're running on?

More information about the Python-list mailing list