[Python-Dev] New string method - splitquoted

Giovanni Bajo rasky at develer.com
Thu May 18 10:21:07 CEST 2006


Heiko Wundram <me+python-dev at modelnine.org> wrote:

> Don't get me wrong, I personally find this functionality very, very
> interesting (I'm +0.5 on adding it in some way or another),
> especially as a
> part of the standard library (not necessarily as an extension to
> .split()).


It's already there. It's called shlex.split(), and follows the semantic of a
standard UNIX shell, including escaping and other things.

>>> import shlex
>>> shlex.split(r"""Hey I\'m a "bad guy" for you""")
['Hey', "I'm", 'a', 'bad guy', 'for', 'you']

Giovanni Bajo



More information about the Python-Dev mailing list