os.system function

Chris Rebert clp2 at rebertia.com
Mon Jan 11 23:36:50 CET 2010

On Mon, Jan 11, 2010 at 2:00 PM, Zabin <zabin.farishta at gmail.com> wrote:
> 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.


More information about the Python-list mailing list