You should never have to shell quote. The correct way to do a command is to not do shell quoting and instead use subprocess.call or subprocess.Popen, and pass a list of unquoted arguments. This is immune to shell expansion.
i.e.
subprocess.Popen(['echo', '"', '$foo'], shell=False)
If you want to unquote shell quoted data, you can use shlex.shlex like this:
list(shlex.shlex("hello stack 'overflow'\''s' quite cool"))