PyDocs

Nav

Unix-specific services

quote

shlex

function · Added in 3.3 (source)
  • quote(s)
Return a shell-escaped version of the string *s*.
1 Example
>>> from shlex import quote
>>> command = 'ls -l {}'.format(quote(filename))
>>> print(command)
ls -l 'somefile; rm -rf ~'
>>> remote_command = 'ssh home {}'.format(quote(command))
>>> print(remote_command)
ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"''
from the Python docs
See Also
No see-alsos for shlex/quote
0 Notes
No notes for quote