Re: [Python-Dev] [Python-checkins] r60919 - peps/trunk/pep-0008.txt
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 21, 2008, at 11:21 AM, skip.montanaro wrote:
Author: skip.montanaro Date: Thu Feb 21 17:21:15 2008 New Revision: 60919
Modified: peps/trunk/pep-0008.txt Log: Replace "looks ugly" with a hopefully more concrete explanation of why line wrapping is bad - it disrupts the visual structure of the code.
Modified: peps/trunk/pep-0008.txt = = = = = = = = ====================================================================== --- peps/trunk/pep-0008.txt (original) +++ peps/trunk/pep-0008.txt Thu Feb 21 17:21:15 2008 @@ -77,10 +77,11 @@
There are still many devices around that are limited to 80 character lines; plus, limiting windows to 80 characters makes it possible to have - several windows side-by-side. The default wrapping on such devices looks - ugly. Therefore, please limit all lines to a maximum of 79 characters. - For flowing long blocks of text (docstrings or comments), limiting the - length to 72 characters is recommended. + several windows side-by-side. The default wrapping on such devices + disrupts the visual structure of the code, making it more difficult to + understand. Therefore, please limit all lines to a maximum of 79 + characters. For flowing long blocks of text (docstrings or comments), + limiting the length to 72 characters is recommended.
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this. Personally, I see no justification for it, and further, it's a pita to support automatically because tools like Emacs only have one auto- wrapping variable (fill-column). Emacs doesn't know that it should fill comments and docstrings different than code lines, so you have to do a bunch of manual crud to support these guidelines. I recommend removing the guideline of 72 characters, and just say everything, code, comments, and docstrings should be no wider than 79 characters. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR72xlXEjvBPtnXfVAQKEdAP/f1xnvn6jw04yyhSZfqA6HdgnYnpnYPAl S4ixszL8phg6KRq8CD2ceskY8TocDg+GG6c//M+jihRRzXMXHW/1Lfp/6syqAd1d vkWaUffaSK4rReMiEG0EmFZmYwaJA660RU0YBnv1d1Idpexj4Y/kIgfgou9OkWDY iJO+efk93Xc= =qYfT -----END PGP SIGNATURE-----
On Thu, Feb 21, 2008 at 9:15 AM, Barry Warsaw
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this.
People in your company have too much time on their hands. :-)
Personally, I see no justification for it, and further, it's a pita to support automatically because tools like Emacs only have one auto- wrapping variable (fill-column). Emacs doesn't know that it should fill comments and docstrings different than code lines, so you have to do a bunch of manual crud to support these guidelines.
I recommend removing the guideline of 72 characters, and just say everything, code, comments, and docstrings should be no wider than 79 characters.
I'm fine with getting rid of this, but since that originally comes from me, here's my justification. Somehow my Emacs usually defaults to 72 for its fill column. That means that when I reflow text in a block comment or docstring, it'll use this limit. OTOH I don't use anything to automatically fold long code lines: when they start wrapping I manually decide on the best place to break it (and my windows are typically 80 chars wide so I can have several side by side(*)). However there are occasions where I manually format docstrings or comments, and then I will again use 79 as the limit. (*) When is Emacs going to fix the bug where it decides to fold a line that's exactly as wide as the window? This 79 business is really silly, and had to impose on people using other editors. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 21, 2008, at 12:30 PM, Guido van Rossum wrote:
On Thu, Feb 21, 2008 at 9:15 AM, Barry Warsaw
wrote: Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this.
People in your company have too much time on their hands. :-)
C'mon, bike shedding is so much fun! :)
Personally, I see no justification for it, and further, it's a pita to support automatically because tools like Emacs only have one auto- wrapping variable (fill-column). Emacs doesn't know that it should fill comments and docstrings different than code lines, so you have to do a bunch of manual crud to support these guidelines.
I recommend removing the guideline of 72 characters, and just say everything, code, comments, and docstrings should be no wider than 79 characters.
I'm fine with getting rid of this, but since that originally comes from me, here's my justification. Somehow my Emacs usually defaults to 72 for its fill column. That means that when I reflow text in a block comment or docstring, it'll use this limit. OTOH I don't use anything to automatically fold long code lines: when they start wrapping I manually decide on the best place to break it (and my windows are typically 80 chars wide so I can have several side by side(*)).
I do the same thing sometimes too.
However there are occasions where I manually format docstrings or comments, and then I will again use 79 as the limit.
Yep.
(*) When is Emacs going to fix the bug where it decides to fold a line that's exactly as wide as the window? This 79 business is really silly, and had to impose on people using other editors.
In 50 years, our grandchildren will be writing code with brain implants and displays burned right into their retina, and they'll / still/ be subject to 79 characters. I laugh every time I think that they'll have no idea why it is, but they'll still be unable to change it. :) - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR79gjHEjvBPtnXfVAQLn/AQApsNQ7KvoBM6wJgKUDHkS97Sd0qTYeRCy qjFQE/hUtAGebqic3fcAEP3ASPp12fOnBpOWOxm0aQURoDdTi+ClTsXp6v/1aztf 9yC1xT3BH022Te82d3vLgRhixxregHZ+5i8ravb3Tb/xdUa3gouql+DyJw8tEAek MGMdcrqoEfE= =FiB+ -----END PGP SIGNATURE-----
On Fri, 22 Feb 2008 18:53:48 -0500 Barry Warsaw
In 50 years, our grandchildren will be writing code with brain implants and displays burned right into their retina, and they'll / still/ be subject to 79 characters. I laugh every time I think that they'll have no idea why it is, but they'll still be unable to change it. :)
There are reasons (other than antiquated media formats) for a coding
standard to mandate a line length of 70-80 characters: to improve the
readability of the source code. Depending on who (and how) you ask,
the most comfortable line length for people to read will vary some,
but 70 characters is close to the maximum you'll get, because it gets
harder to track back across the page as lines get longer. While code
is so ragged that that's probably not as much of a problem, comments
aren't. Formatting those to a max of ~70 characters makes them easy to
read. Formatting your program so that block comments and code are
about the same makes optimal use of the display space.
Whether the readability issue has anything to do with why 80 column
cards dominated the industry (some were as short as 24 columns, and I
could swear I saw a reference to 120-column cards *somewhere*) is left
as an exercise for the reader.
Barry Warsaw wrote:
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this.
I'm not sure if this is the main reason, but when using pydoc to view docstrings, the 72 character width allows for the added indent in class and method sections. Ron
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 21, 2008, at 12:33 PM, Ron Adam wrote:
Barry Warsaw wrote:
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this.
I'm not sure if this is the main reason, but when using pydoc to view docstrings, the 72 character width allows for the added indent in class and method sections.
Interesting. Maybe because I almost always put doctests in separate files, I don't run into this too much. Having an indent of 4 for doctest code never really bothers me too much. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR79fdnEjvBPtnXfVAQKL0gP8DiLPO6bQEIwvcg9M7ke9Dl8QYMf3+KSV TY7o20ogh54mnm66YElJ3HFU1iomOx6CsP0gNJ2mioKCJj3iBAdGKmPb0KhJKiDa bLZc0y2Pmzw//ePspkIGZrEjDm8vps5A/iRGF58tnMdYg6f/OzfJPAmGNo6rzOl8 pI27IxE4XX4= =Xe/I -----END PGP SIGNATURE-----
Barry Warsaw wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Feb 21, 2008, at 12:33 PM, Ron Adam wrote:
Barry Warsaw wrote:
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this. I'm not sure if this is the main reason, but when using pydoc to view docstrings, the 72 character width allows for the added indent in class and method sections.
Interesting. Maybe because I almost always put doctests in separate files, I don't run into this too much. Having an indent of 4 for doctest code never really bothers me too much.
I think the 72 character limit refers to the length of the doc string, not the length of the line. Pydoc, ie...the help() function, strips leading white space off and then adds it's own margin, 4 characters for function doc strings, and 8 characters with a vertical bar for class method doc strings. Longer than 72 character doc strings in class methods wrap and break up the output of the help function. Ron
On Thu, Feb 21, 2008 at 9:15 AM, Barry Warsaw
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Feb 21, 2008, at 11:21 AM, skip.montanaro wrote:
Author: skip.montanaro Date: Thu Feb 21 17:21:15 2008 New Revision: 60919
Modified: peps/trunk/pep-0008.txt Log: Replace "looks ugly" with a hopefully more concrete explanation of why line wrapping is bad - it disrupts the visual structure of the code.
Modified: peps/trunk/pep-0008.txt = = = = = = = = ====================================================================== --- peps/trunk/pep-0008.txt (original) +++ peps/trunk/pep-0008.txt Thu Feb 21 17:21:15 2008 @@ -77,10 +77,11 @@
There are still many devices around that are limited to 80 character lines; plus, limiting windows to 80 characters makes it possible to have - several windows side-by-side. The default wrapping on such devices looks - ugly. Therefore, please limit all lines to a maximum of 79 characters. - For flowing long blocks of text (docstrings or comments), limiting the - length to 72 characters is recommended. + several windows side-by-side. The default wrapping on such devices + disrupts the visual structure of the code, making it more difficult to + understand. Therefore, please limit all lines to a maximum of 79 + characters. For flowing long blocks of text (docstrings or comments), + limiting the length to 72 characters is recommended.
Why should docstrings and comments be limited to 72 characters when code is limited to 79 characters? I ask because there is an ongoing debate at my company about this.
Personally, I see no justification for it, and further, it's a pita to support automatically because tools like Emacs only have one auto- wrapping variable (fill-column). Emacs doesn't know that it should fill comments and docstrings different than code lines, so you have to do a bunch of manual crud to support these guidelines.
I recommend removing the guideline of 72 characters, and just say everything, code, comments, and docstrings should be no wider than 79 characters.
+1 from me. I know having a separate line break rule just for PEPs and such is a pain as I am having to constantly look down at the column number to know when I have run afoul of this. -Brett
Why not just skip the specifics except to say < 80 characters for all lines? Don't mention 72, 79 or any other number than 80: Maximum Line Length There are still many devices around that are limited to 80 character lines; plus, limiting windows to 80 characters makes it possible to have several windows side-by-side. The default wrapping on such devices disrupts the visual structure of the code, making it more difficult to understand. Therefore, please limit all lines to less than 80 characters. ... Skip
Skip Montanaro wrote:
Why not just skip the specifics except to say < 80 characters for all lines? Don't mention 72, 79 or any other number than 80:
I often run "svn diff" in a console limited to 80 characters. Because of the leading "+", lines longer than 78 wrap, and the output is more difficult to read. -- Amaury Forgeot d'Arc
And this is then compounded if you then proceed to diff those diff outputs. Maybe we should just use vertical spacing?
-----Original Message----- From: python-dev-bounces+kristjan=ccpgames.com@python.org [mailto:python-dev-bounces+kristjan=ccpgames.com@python.org] On Behalf Of Amaury Forgeot d'Arc Sent: Friday, February 22, 2008 08:01 To: Skip Montanaro Cc: python-dev Dev Subject: Re: [Python-Dev] [Python-checkins] r60919 - peps/trunk/pep- 0008.txt
Skip Montanaro wrote:
Why not just skip the specifics except to say < 80 characters for all lines? Don't mention 72, 79 or any other number than 80:
I often run "svn diff" in a console limited to 80 characters. Because of the leading "+", lines longer than 78 wrap, and the output is more difficult to read.
>> Why not just skip the specifics except to say < 80 characters for all >> lines? Don't mention 72, 79 or any other number than 80: Amaury> I often run "svn diff" in a console limited to 80 characters. Amaury> Because of the leading "+", lines longer than 78 wrap, and the Amaury> output is more difficult to read. There will always be certain cases which present probems. I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping. Skip
On Fri, Feb 22, 2008 at 10:12:16AM -0600, skip@pobox.com wrote:
I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping.
svn blame | less -S Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
On Fri, Feb 22, 2008, skip@pobox.com wrote:
>> Why not just skip the specifics except to say < 80 characters for all >> lines? Don't mention 72, 79 or any other number than 80:
Amaury> I often run "svn diff" in a console limited to 80 characters. Amaury> Because of the leading "+", lines longer than 78 wrap, and the Amaury> output is more difficult to read.
There will always be certain cases which present probems. I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping.
Yes, but svn/cvs diff is a particularly common use case. I agree with Amaury. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "All problems in computer science can be solved by another level of indirection." --Butler Lampson
On Fri, Feb 22, 2008 at 8:20 AM, Aahz
On Fri, Feb 22, 2008, skip@pobox.com wrote:
>> Why not just skip the specifics except to say < 80 characters for all >> lines? Don't mention 72, 79 or any other number than 80:
Amaury> I often run "svn diff" in a console limited to 80 characters. Amaury> Because of the leading "+", lines longer than 78 wrap, and the Amaury> output is more difficult to read.
There will always be certain cases which present probems. I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping.
Yes, but svn/cvs diff is a particularly common use case. I agree with Amaury.
-1. There's just no way that 78 is enforceable. At Google, sticking to 80 is a continuous battle, and we use 2-space indents! -- --Guido van Rossum (home page: http://www.python.org/~guido/)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 22, 2008, at 11:28 AM, Guido van Rossum wrote:
On Fri, Feb 22, 2008 at 8:20 AM, Aahz
wrote: On Fri, Feb 22, 2008, skip@pobox.com wrote:
Why not just skip the specifics except to say < 80 characters for all lines? Don't mention 72, 79 or any other number than 80:
Amaury> I often run "svn diff" in a console limited to 80 characters. Amaury> Because of the leading "+", lines longer than 78 wrap, and the Amaury> output is more difficult to read.
There will always be certain cases which present probems. I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping.
Yes, but svn/cvs diff is a particularly common use case. I agree with Amaury.
-1. There's just no way that 78 is enforceable. At Google, sticking to 80 is a continuous battle, and we use 2-space indents!
At my last job, I had a hard enough time getting people to stick with / any/ limit! I even saw lines > 120 characters! Fortunately, we made a workable compromise; the C code could be whatever and the Python code had to be PEP 8. :) - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR79fB3EjvBPtnXfVAQLBNAP7BD1FG5bOjkP0iys2r6f6nK98D9XZhK3J Qm+Cjm6tmnqEv92R9rEVYOIH0KE21oGhJFliOccYZzuE0WFPk9T6KXrRIAmggBrf ZtAwcj//0dfkq/7XGWwKgx9B7BoCymyyKGo16svj/jGeBQM6dLSoKUP+Fbw6zJEF n04bAwAqFp0= =3kW3 -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 22, 2008, at 11:20 AM, Aahz wrote:
On Fri, Feb 22, 2008, skip@pobox.com wrote:
Why not just skip the specifics except to say < 80 characters for all lines? Don't mention 72, 79 or any other number than 80:
Amaury> I often run "svn diff" in a console limited to 80 characters. Amaury> Because of the leading "+", lines longer than 78 wrap, and the Amaury> output is more difficult to read.
There will always be certain cases which present probems. I use "svn annotate" from time-to-time which adds an even wider margin to the left. In those situations I either grin and bear it or stretch my window enough to view it without wrapping.
Yes, but svn/cvs diff is a particularly common use case. I agree with Amaury.
My main concern is that we have only one line length limit for everything. If we want that to be 78 or 72 or whatever, okay (though I still think 79 works well :) but I don't see much point in there being more than one limit. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR79g/HEjvBPtnXfVAQJCCQP/Qd7nWrSC3Wm6Y4+dPgv0ls1Td3ZTuf7n ZzE6cIiV0h2tgKsS+olRHE2e/ttKNVRask2FPrhUClj4eXG6k3bVU/KsH9JR4wjH Ha1ayDb74ZHqqdSZKrKCcsak5fismBv2Vsn8aDI3eslzFVEd0FF1dU+qQYf/m3je 2gjt9Fx6wYU= =6WAr -----END PGP SIGNATURE-----
participants (11)
-
Aahz
-
Amaury Forgeot d'Arc
-
Barry Warsaw
-
Brett Cannon
-
Guido van Rossum
-
Kristján Valur Jónsson
-
Mike Meyer
-
Oleg Broytmann
-
Ron Adam
-
Skip Montanaro
-
skip@pobox.com