Greedy triple-quoted string literals

Lars T Hansen lth at
Mon Feb 18 02:08:33 PST 2008

The correct interpretation is that a triple quoted string starts with
three quotes of the same kind and ends when the same three quotes are
seen in sequence provided that the character following the three is
not that same quote character.

(Whether you want to call that greedy or not depends on whether you
think it's greedy to take what you can when you can take it, or
whether you think it's greedy to avoid taking something now because
you think you can take more later.  Generally speaking a greedy
algorithm is one that makes a locally optimal choice about what is
best, so I think the description on the wiki is OK.  The above
description is more precise.)


On Feb 18, 2008 10:56 AM, Dominic Cooney <dominic.cooney at> wrote:
> There's a note on the triple-quoted string literals proposal*:
> "we decided that triple-quoted strings would be greedy when looking
> for the closing triple-quotes."
> Wouldn't this mean, in practice, that it is only possible to have two
> triple-quoted string literals per source file (one with """ and
> another with ''')?
> *
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list