Home

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 csv

s = 'abc "xy z" "1 2 3" "a \\" x"'
r = iter(csv.reader([s], delimiter=" ", escapechar="\\"))
print r.next()

w.

previous
next

Re: What's the difference between the priority queue & set & heap?
Re: unexpected optparse set_default/set_defaults behavior
C# calling C++ error (instruction at referenced memory could not be read)
Re: Superclass and Subclasses
Re: Dynamically removing methods in new-style classes
Fundacja Sloneczko
Pajacyk
Mimo Wszystko
Kidprotect
Rodzic Po Ludzku