Parsing parameters with quotes

Giovanni Bajo noway at sorry.com
Fri Mar 14 16:12:34 EST 2003


"Alex Martelli" <aleax at aleax.it> ha scritto nel messaggio
news:l5hca.55547$pG1.1276278 at news1.tin.it...

> and similarly for module tokenize:
>
> import tokenize
> print [t[1] for t in tokenize.generate_tokens(si(xx).readline) if t[1]]
>
> emits:
>
> ['foo', '"this is one"', 'and', 'this', 'is', 'not']
>
> However, removing the quotes when present shouldn't be too hard, I think.

Sure, t[1].strip('"') is enough.

I should look into the tokenizers, I don't know them at all. Thanks for the
help.

Giovanni Bajo






More information about the Python-list mailing list