How can I reverse the results of a shlex.split? That is, how can I obtain a quoted string that would \"resemble that of a Unix shell\", given a list of strings
list
How about using pipes.quote?
pipes.quote
import pipes strings = ["ls", "/etc/services", "file with spaces"] " ".join(pipes.quote(s) for s in strings) # "ls /etc/services 'file with spaces'"
.