Python - Split a string by spaces — preserving quoted substrings

>>> import shlex
>>> shlex.split('this is "a test"')
['this', 'is', 'a test']