os.popen2 vs popen2.popen2
Spot the difference:
Python 2.5.2 (r252:60911, Aug 6 2008, 09:17:29) [GCC 4.3.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> def p(string): ... print re.sub(r'\n +', '\n', string) ... >>> >>> import os >>> p(os.popen2.__doc__) Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If 'cmd' is a string it will be passed to the shell (as with os.system()). If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdin, child_stdout) are returned. >>> >>> import popen2 >>> p(popen2.popen2.__doc__) Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If 'cmd' is a string it will be passed to the shell (as with os.system()). If 'bufsize' is specified, it sets the buffer size for the I/O pipes. The file objects (child_stdout, child_stdin) are returned. >>>
It took me a while to realize why my program was failing since I was reading the documentation for one version and using the other :-)