Quotation Ugliness
Tim Chase
python.list at tim.thechases.com
Tue Nov 25 19:40:00 EST 2014
On 2014-11-25 18:18, Tim Daneliuk wrote:
> A problem for your consideration:
>
> We are given a tuple of delimiter string pairs to quote or comment
> text, possibly over multiple lines. Something like this:
>
> delims = (('"', '"'), ("'", "'"), ('#', '\n'), ("\*", "*\),
> ('\\', '\n') ...)
>
> These may be nested.
>
> Here's the problem: Determine is the string S appears *outside* or
> *inside* any such quotation.
You would have to define what should happen in a case where you have
more than one single/double-quote delimited items on the same line:
do("this", "and", "that")
should it return true or false when testing for 'this", "and",
"that'? (it is within double-quotes)
And what should happen with mismatched quotes?
do("th/*is", "and", "th*/at")
It would also help to have a proposed function signature for the
functionality you want. Something like
def inside_quote(s, corpus, delims=delims):
-tkc
More information about the Python-list
mailing list