Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5240
| Date | 2011-05-12 15:21 +0100 |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| Subject | Re: os.popen command working differently on Windows |
| References | <21581D39FA3BDF40904D75AF9653CE26064FC6D1@blrex.prog.altair.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1469.1305210153.9059.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: os.popen command working differently on Windows Tim Golden <mail@timgolden.me.uk> - 2011-05-12 15:21 +0100 Re: os.popen command working differently on Windows Nobody <nobody@nowhere.com> - 2011-05-13 09:48 +0100 Re: os.popen command working differently on Windows Hans Mulder <hansmu@xs4all.nl> - 2011-05-13 19:10 +0200
csiph-web