split string saving screened spaces

Giovanni Bajo noway at sorry.com
Fri Dec 16 09:47:52 CET 2005


Sergey wrote:

> Which module to use to do such thing:

> "-a -b -c '1 2 3'" -> ["-a", "-b", "-c", "'1 2 3'"]


>>> import shlex
>>> shlex.split("-a -b -c '1 2 3'")
['-a', '-b', '-c', '1 2 3']

-- 
Giovanni Bajo





More information about the Python-list mailing list