Trying to split a string by whitespace, while preserving contents enclosed in curly/smart quotes (“”), by using shlex module in Python 3.6.3. However, it does not work properly:
>>> import shlex
>>> text = 'one “two and three” four'
>>> shlex.split(text)
['one', '“two', 'and', 'three”', 'four']
Using normal quotes ("), works as expected:
>>> text = 'one "two and three" four'
>>> shlex.split(text)
['one', 'two and three', 'four']
So, how do I get shlex to work with qurly/smart quotes?