[Python-ideas] Line continuations with comments

Christian Tismer tismer at stackless.com
Sun Jun 9 21:52:49 CEST 2013


On 23.05.13 01:15, Ron Adam wrote:
>
> I'm not sure why some people dislike the back slash so much as a 
> continuation tool.  Python is the language that avoids using {braces 
> around blocks}, so you'd think it would be the other way around.
>
> I really don't think the '\' will be over used.  New programmers do 
> try a lot of strange things at first for making their own programs 
> easier to read, (I did), but usually they come around to what the 
> community practices and recommends.
>

I think the reason that people don't like the '\' is that it opens up so 
many
bad memories:

- having to use them inside C macros
- having to deal with it on windows
- felt unpythonic because it is a low-level trick to produce longer lines

Especially the unpythonic feeling comes from the fact that '\' either has
special meaning in strings (which is accepted) or has very restricted use
outside of strings:

     there must not be anything but the line end after it.

So by lifting the usability of '\' to allow comments after it makes it from
an ugly left-over C feature into something useful that people _want_ to use
for splitting the continuation of something from the comments.

I think after introducing it, the bad prejudice will vanish.

The mental change is from "a hack because the line doesn't fit"
into "a well-formed structuring tool to split code and comment"...

cheers - chris

>
>>     <snip>
>>
>>     The reason \# works, but not \ #, is when the comment comes directly
>>     after the back slash, it's removed and leaves a (backslash + 
>> new-line)
>>     pair.
>>
>>
>> Whether we require there be no space between \ and # or, conversely,
>> require there be at least one whitespace character should not be 
>> based on
>> the relative ease of patching the current code. Personally, I would 
>> prefer
>> the latter as I believe requiring a space after \ will increase 
>> readability.
>
> My preference is to allow any number of spaces before and after the 
> '\'. and that any comments after the slash not change what it means.
>
> A built in single space rule would probably frustrate people who don't 
> want to do it that way.  Like how you get a character after a 
> continuation error, even if it's only a single space.  Yeah, it's how 
> it works, but it's still annoying to get that error in that situation.
>
> A comment of course, would still uses up the rest of the line. So a 
> '\' after '#' is just part of the comment.
>
>
> Cheers,
>    Ron
>
>
>
>
>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas


-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Software Consulting          :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/



More information about the Python-ideas mailing list