Tony wrote:
With Python 2.4 I get these results (all imports are factored out, all give
the same result except for CSV which strips the "s) with timeit.py:
Just a note here in terms of results. Although the
results are all the same and they work for the case where there is
single quoted phrase with more than one word in it, the
split_and_rejoin has problems for the case where there is only a single
word in quotes (since the trailing quote that you are assuming is in
another word occurs in the same word and thus is never found). e.g. 'I
said "wow" when I saw the result' will give it problems.
The re _expression_ has a problem if there is more than one
quoted string in the string (e.g. 'if "this" and "that" are quoted').
The reason is that the _expression_ is "greedy" and matches the longest
string of characters between quote marks: in '"this" and "that"' the
entire string will be matched rather than the first "this". The fix is
to use the non-greedy pattern:
re.compile(r'\".*?\"|[^ ]+')
Note the ? after the *
/c
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor