Quote shell characters

Sometimes it’s nice to be able to display a command being run and do it in a form that can be repeated from a terminal window. Unfortunately, I’ll build a command in python like this:

The trivial answer of ‘ ‘.join (args) produces something that can’t be passed to the shell:

Here is a code fragment and some attached tests that provide better quoting. It’s used like this:

And the result of running this: