split string saving screened spaces

Giovanni Bajo noway at sorry.com
Fri Dec 16 03:47:52 EST 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