2 new comment-like characters in Python to aid development?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 9 11:13:09 CET 2007

En Fri, 09 Mar 2007 06:14:46 -0300, <dbhbarton at googlemail.com> escribió:

> A '?' placed in the preceding whitespace of a line as a means of
> quickly highlighting a line or block of code for special attention.
> The interpreter simply ignores these characters, and executes the code
> as if each WIP character wasn't there. The value-added comes from how
> IDEs can exploit this to color the line or code block (in a
> customisable fashion as with other context-dependent IDE formatting).

This could be implemented without new syntax: just make your editor  
recognize some special comments, and apply the highlighting to the  
following block. By example,

		# XXX Remove this when FuruFaifa is fixed to always provide
		# XXX the names in the same order

		if names==oldnames:

would highlight the first 4 lines (let's say, up to the next blank line or  

> 2. The HALT comment:
> A '!' at the start of a line, indicating the end of the script proper.
> The interpreter would register this one, and ignore everything after
> it, a bit like a sys.exit() call but also stopping it from picking
> syntax errors after the HALT. IDEs could then 'grey out' (or 'yellow
> out' or whatever) all following characters, including later HALT
> comments.

You accidentally type a ! somewhere, and your module stops working - not  
so good :( and worse, hard to find.

I sometimes use '''this string marks''' to ignore whole blocks of code. It  
works fine unless the block already contains the same kind of  
triple-quoted string...

> As far as I can see, neither of these would break backwards
> compatibility and, like the @ decorator, if you don't like it, you
> wouldn't have to use it. I don't know enough about the guts of Python
> to say much about ease of implementation, but it doesn't seem like it
> would be too hard.

The main problem with new syntax is breaking compatibility with older  
versions, and I doubt it's worth the pain just for highlighting or playing  
interactively, so you don't have a great chance of them being  

Gabriel Genellina

More information about the Python-list mailing list