The on-line documentation states that os.popen is now deprecated. All other deprecated functions duly raise a DeprecationWarning. For instance:
>>> import os
>>> [c.close() for c in os.popen2('ps h -eo pid:1,command')]
__main__:1: DeprecationWarning: os.popen2 is deprecated. Use the subprocess module.
[None, None]
The function os.popen, on the other hand, completes silently:
>>>len(list(os.popen('ps h -eo pid:1,command')))
202
Without raising a warning. Of the three possible scenarios
- It is expected behaviour that documentation and standard library have different ideas of what is deprecated;
- There is an error in the documentation and os.popen is not really deprecated;
- There is an error in the standard library and os.popen should raise a warning;
which one is the correct one?
For background information, here's the Python I'm using:
>>> import sys
>>> print sys.version
2.6.2 (r262:71600, May 12 2009, 10:57:01)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)]
The argument to os.popen is taken from a reply of mine here on Stack Overflow.
Addendum: Thanks to cobbal below, it turns out that os.popen is not deprecated in Python 3.1, after all.