Re: Quote aware split

2007-05-16 Thread Diez B. Roggisch
Ondrej Baudys wrote: Hi, After trawling through the archives for a simple quote aware split implementation (ie string.split-alike that only splits outside of matching quote) and coming up short, I implemented a quick and dirty function that suits my purposes. snip/ Maybe using the csv

Re: Quote aware split

2007-05-16 Thread BJörn Lindqvist
How is the code different from shlex.split? -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list

Re: Quote aware split

2007-05-16 Thread John Machin
On May 16, 10:50 am, Ondrej Baudys [EMAIL PROTECTED] wrote: # last slice will be of the form chars[last:] which we couldnt do above Who are we? Here's another version with the couldn't do problem fixed and a few minor enhancements: def qsplit2(chars, sep=,, quote='): Quote aware split

Re: Quote aware split

2007-05-16 Thread Tim Arnold
Ondrej Baudys [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, After trawling through the archives for a simple quote aware split implementation (ie string.split-alike that only splits outside of matching quote) and coming up short, I implemented a quick and dirty function

Re: Quote aware split

2007-05-16 Thread obaudys
On May 16, 8:51 pm, BJörn Lindqvist [EMAIL PROTECTED] wrote: How is the code different from shlex.split? Shlex only splits by whitespace. I needed something to split out SQL statements from a Postgresql dump, so the ideal way of doing that is to split by semicolons. However, postgresql

Quote aware split

2007-05-15 Thread Ondrej Baudys
Hi, After trawling through the archives for a simple quote aware split implementation (ie string.split-alike that only splits outside of matching quote) and coming up short, I implemented a quick and dirty function that suits my purposes. It's ugly and it doesn't use a stack, it only supports

Re: Quote aware split

2007-05-15 Thread Gabriel Genellina
En Tue, 15 May 2007 21:50:15 -0300, Ondrej Baudys [EMAIL PROTECTED] escribió: After trawling through the archives for a simple quote aware split implementation (ie string.split-alike that only splits outside of matching quote) and coming up short, I implemented a quick and dirty function

Re: Quote aware split

2007-05-15 Thread obaudys
On May 16, 1:18 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: The is operator checks object *identity*, that is, if both operands are actually the same object. It may or may not work here, depending on many implementation details. You really should check if they are *equal* instead: