os.system function

Chris Rebert clp2 at rebertia.com
Mon Jan 11 17:36:50 EST 2010


On Mon, Jan 11, 2010 at 2:00 PM, Zabin <zabin.farishta at gmail.com> wrote:
<snip>
> and just wondering- whats the drawback of using os.system() command

Forgetting to properly escape your input. Simple example:

filename = "foo bar.txt"
os.system("rm "+filename) # uh-oh, we deleted 'foo' and 'bar.txt' instead

The `subprocess` module makes escaping unnecessary.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list