How to handle multi-line quotes

Hendrik van Rooyen mail at microcorp.co.za
Sat Dec 22 04:20:17 EST 2007


MartinRinehart wrote:

> 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?

Warning:  You don't want to hear this, but you did ask...
======

It depends on context in my mind.

If I am typing a new string, I want it to automatically add the trailing quotes
and leave the cursor between them, ready for entry, until I use the arrow
keys or the mouse to get "out of" the string.

If I am commenting out a piece of code, I want it to give me the default
behaviour - chunking the rest of the file in one big lump until I insert the
closing quotes.

But alas - it has always been thus - I seldom get what I want, because
people and things always seem to misinterpret my intentions.

So I will settle for the default initial behaviour, with a switch to the first
style when I type the first displayable character after the opening quotes.

Or the opposite, start with the full set of delimiters, the cursor between
them, and if the cursor moves out of the empty string, fall back to the
lumpy behaviour by removing the closing delimiters.

Both would force one to explicitly define an empty string, but that is
just the way the world works now, so that is fine by me.

And just to make your day, I want the behaviour to nest or not, to give
me control over how it works, and while we are parameterising - why not
something to choose between the three styles?  - you could define some
globals, and write a lot more code.  (and yes its three not two - think about
it)

Do you sometimes feel that becoming a fireman or a pizza salesman
would have led to a less complicated life?

- Hendrik





More information about the Python-list mailing list