os.popen command working differently on Windows
Tim Golden
mail at timgolden.me.uk
Thu May 12 10:21:41 EDT 2011
On 12/05/2011 15:11, Ayaskanta Swain wrote:
> Please help me in solving the following issue I am facing while
> executing my python script. Basically I am executing the OS specific
> move command to move a file/dir from one location to another.
Why? Why not use os.rename or shutil.move which already do
whatever is needed under the covers for different Operating Systems?
os.popen returns a file-like object from which you can read any
error messages generated. You're not doing that, and os.popen
won't raise an error itself unless you, say, pass it a number
rather than a string.
<code>
import os
output = os.popen ("dir")
print output.read ()
#
# But note:
#
os.popen ("Nonsen*se")
# raises no exception
</code>
TJG
More information about the Python-list
mailing list