How to handle multi-line quotes

MartinRinehart at gmail.com MartinRinehart at gmail.com
Fri Dec 21 14:15:36 EST 2007


Thinking about unclosed multi-line quotes.

When you open a multi-line quote (type '"""') what does your editor
do? Does it color the remainder of your text as a quote, or does it
color the line with the open quote as a quote and leave the rest of
your code alone?

What do you want it to do?

This is a tokenizer question in disguise, of course. The simple way to
handle it, which is what my editor sees, is for the tokenizer to
return the remainder of the text as one great UNCLOSED_MULTILINE_QUOTE
token. The alternative is to assume that the line with the unclosed
quote is in error and to continue to tokenize the rest. An editor
might blink or otherwise draw attention to the unmatched quote.



More information about the Python-list mailing list