[Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

Modulok modulok at gmail.com
Thu Sep 20 21:25:59 CEST 2012


> I forgot you need to escape special characters in the arguments. You
> can add quoting and escape special characters at the same time with
> the undocumented function pipes.quote:
>
>     import pipes
>
>     args = tuple(pipes.quote(arg) for arg in (arg1, arg2, arg3))
>     cmd = 'python test.py %s %s %s' % args
>
> Notice there are no longer quotes around each %s in cmd. Python 3.3
> will have shlex.quote:
>
> http://docs.python.org/dev/library/shlex.html#shlex.quote

Why is ``pipes.quote`` undocumented? It's useful.

-Modulok-


More information about the Tutor mailing list