Home

On Tue, 2007-07-31 at 22:30 +0200, Helmut Jarausch wrote:
> Hi,
>
> I'm looking for an elegant solution to the following (quite common)
> problem:
>
> Given a string of substrings separated by white space,
> split this into tuple/list of elements.
> The problem are quoted substrings like
>
> abc "xy z" "1 2 3" "a \" x"
>
> should be split into ('abc','xy z','1 2 3','a " x')

>>> import shlex
>>> shlex.split('abc "xy z" "1 2 3" "a \\" x"')
['abc', 'xy z', '1 2 3', 'a " x']

I hope that's elegant enough ;)

--
Carsten Haese
http://informixdb.sourceforge.net

previous
next

Re: Handwriting Recognition
Re: Game of craps giving class error
Re: i am new to python-Please somebody help
Re: frange() question
Re: How to read a binary file larger than 2GB on a 32-bit system
akcesoria komputerowe
kamery sportowe
Archiwizacja danych online
poker
tusze do drukarek