Quotation Ugliness

Tim Daneliuk tundra at tundraware.com
Wed Nov 26 01:18:24 CET 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.

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

More information about the Python-list mailing list