January 5th, 2013, 05:30 PM
From the manual:
Yes, the mode argument is optional, defaulting to 'r'. Obviously, if you do choose to supply the optional argument, it has to have an appropriate value: as the description states, it needs to be 'r' or 'w', allowing you respectively to read from or write to the subprocess. The fact that the mode is not a required argument doesn't allow you to give it a nonsense value, like "sys.stdout" or mfile.name().
Originally Posted by boragora
While we're here, the manual goes on to say:
There's nothing os.popen does that subprocess.Popen doesn't do better. For example, with subprocess.Popen, you can access all three standard I/O streams of the process (stdin, stdout, and stderr) if you want. os.popen is basically just a work-alike for the C standard library function of the same name, while the subprocess module is designed specifically for Python.
January 7th, 2013, 11:20 AM
As to nonsensical values: hence the reason I later referred to it as a brain cramp.
Certainly not something worth biting someone's head off for...