Wrapping comments

MRAB google at mrabarnett.plus.com
Mon May 11 14:38:03 EDT 2009


norseman wrote:
> Tobias Weber wrote:
>> Hi,
>> the guideline (PEP 8) is hard wrap to 7x characters. The reason given 
>> is that soft wrap makes code illegible.
>>
>> So what if you hard wrap code but let comments and docstrings soft-wrap?
>>
>> Otherwise it's hugely annoying to edit them. Say you remove the first 
>> three words of a 150 character sentence. Either keep the ugly or 
>> rewrap manually.
>>
>> Or are there editors that can do a "soft hard wrap" while keeping 
>> indentation and #comment markers intact?
>>
> 
> =======================
> Paragraph 1:  65 and 72 cols are US typewriter standard 12 and 10 pt
>               respectively. (MSDOS screen, business standard paper, ..)
>               And yes, soft wrap does. Check the hardcopy which wraps
>               code with lots of long lines.
> 
> Paragraph 2:  Comments? I vote no. These are in the code and should
>               conform to helping at that location.
>               Doc_stuff - I vote yes. For the obvious reason that it
>               makes formating the Docs easier AND is to be 'extracted'
>               to a separate file for that purpose in the first place.
> 
> Paragraph 3:  True
> 
> Could you give a short example of what you are referring to in your last 
> paragraph?  I showed this to several friends and got several 'views' as 
> to what is intended.
> 
I think he means something like:

# 65 and 72 cols are US typewriter standard 12 and 10 pt respectively.

when wrapped to 40 gives:

# 65 and 72 cols are US typewriter
# standard 12 and 10 pt respectively.

and when rewrapped to 60 gives:

# 65 and 72 cols are US typewriter standard 12 and 10 pt
# respectively.

Indentation of lines wouldn't be affected, so:

         # 65 and 72 cols are US typewriter standard 12 and 10 pt 
respectively.

when wrapped to 40 gives:

         # 65 and 72 cols are US
         # typewriter standard 12 and 10
         # pt respectively.

and when rewrapped to 60 gives:

         # 65 and 72 cols are US typewriter standard 12 and
         # 10 pt respectively.

> 
> I assume you are NOT intending to use third party programs to write code 
> in but rather to use Python somehow?
> 
> I assume you are intending that the editor add the backslash newline at 
>  appropriate places without causing a word or code break when needed and 
> simply wrapping with indent without breaking the code the rest of the 
> time and doing so in such a fashion that ALL general text editors will 
> be able to display code properly as well as be usable in modifying code?
> Not to mention that the interpreter and/or compiler will still be able 
> to use the file.
> 



More information about the Python-list mailing list