Quotation Ugliness

Tim Daneliuk tundra at tundraware.com
Tue Nov 25 19:18:24 EST 2014


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.

I know lots of ugly/complicated/heavyweight ways to solve this, but I'm
wondering if any of you geniuses have a pythonic/elegant/short algo that
solves this.


TIA,
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/




More information about the Python-list mailing list