Converting an ugly path to a shell path

Jerry Hill malaclypse2 at gmail.com
Mon Sep 13 19:37:08 EDT 2010


On Mon, Sep 13, 2010 at 7:07 PM,  <AmFreak at web.de> wrote:
> The problem that occurs now is when the user selects an "ugly" path like
> this /home/user/!" §$/.
> The shell don't understand the special chars so i have to escape them with
> "\" .
> Is there a function that does this ?

http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python
seems to cover most of the possibilities.

Particularly, do you really need shell=True?  If not, you can just
call Popen([command, path], stdout=PIPE, stderr=PIPE) and not worry
about it.

-- 
Jerry



More information about the Python-list mailing list