PEP8 revised: max line lengths

S

Steven D'Aprano

And the people did rejoice and did feast upon the lambs and toads and
tree-sloths and fruit-bats and orangutans and breakfast cereals.

Except on Python-Dev, where feedback on allowing longer lines is almost
entirely negative. The consensus seems to be, if you have a line of code
that is more than 79 characters, and less than 100 characters, and there
is no clean way to break it over multiple lines, then it is acceptable to
not break it.
 
C

Chris “Kwpolska†Warrick

And the people did rejoice and did feast upon the lambs and toads and
tree-sloths and fruit-bats and orangutans and breakfast cereals.

The 99-characters rule does not apply for the stdlib. And outside of
the stdlib, PEP 8 is not mandated by Python (but it might be by the
project leader or similar entities). If someone wanted long lines,
then they could do so ALL THE TIME.

So, what are you feasting for? Nothing?
 
W

wxjmfauth

Le vendredi 2 août 2013 13:07:47 UTC+2, Chris “Kwpolska” Warrick a écrit :
The 99-characters rule does not apply for the stdlib. And outside of

the stdlib, PEP 8 is not mandated by Python (but it might be by the

project leader or similar entities). If someone wanted long lines,

then they could do so ALL THE TIME.



So, what are you feasting for? Nothing?



--

Chris “Kwpolska” Warrick <http://kwpolska.tk>

PGP: 5EAAEA16

stop html mail | always bottom-post | only UTF-8 makes sense

And do not forget, a monospaced font is never monospaced
(for understandable reasons).
The solely valid solution, assuming there is some wish,
is to define a maximal line width (preferably in SI units ;-)

The day, the devs succeed to think non ascii, is not
arrived.

jmf

PS independently of the CJK stuff.
 
S

Skip Montanaro

The solely valid solution, assuming there is some wish,
is to define a maximal line width (preferably in SI units ;-)

So, 79 * 8 points == 0.222955555696 meters, right? :)

Skip
 
W

wxjmfauth

Le vendredi 2 août 2013 17:19:11 UTC+2, Skip Montanaro a écrit :
So, 79 * 8 points == 0.222955555696 meters, right? :)



Skip

You can correct your mistake yourself. In your
equation, the unit at the left is [1] * [point] = [point],
at the right the unit is [meter], obviously
[point] != [meter].


Problem #1
For a tool which is supposed to be Unicode compliant,
a Unicode compliant font has never a constant pitch,
so counting a maximal width in number of characters
does not make sense.

Problem #2
The only valid constraint which makes sense is
a maximal size in a length unit. Two possibilities:
– if you consider your document is to be viewed
as a screen document, pixel comes in mind.
– if you condider your document will be printed,
retain a physical unit length (cm, inch).

Problem #3
cm or inch? The only serious unit is an SI unit.
(In scientific publications, only SI units are accepted)


Hint: Put you code in a pdf.

jmf
 
C

Chris Angelico

Le vendredi 2 août 2013 17:19:11 UTC+2, Skip Montanaro a écrit :
So, 79 * 8 points == 0.222955555696 meters, right? :)

Skip

You can correct your mistake yourself. In your
equation, the unit at the left is [1] * [point] = [point],
at the right the unit is [meter], obviously
[point] != [meter].

http://en.wikipedia.org/wiki/Point_(typography)

A point is one twelfth of a pica, which is one sixth of an inch, which
is 0.0254 SI millimeters. Do the arithmetic. Skip is absolutely
correct.
Problem #1
For a tool which is supposed to be Unicode compliant,
a Unicode compliant font has never a constant pitch,
so counting a maximal width in number of characters
does not make sense.

Problem #2
The only valid constraint which makes sense is
a maximal size in a length unit. Two possibilities:
– if you consider your document is to be viewed
as a screen document, pixel comes in mind.
– if you condider your document will be printed,
retain a physical unit length (cm, inch).

Problem #3
cm or inch? The only serious unit is an SI unit.
(In scientific publications, only SI units are accepted)

The cm is not a primary SI unit either.
Hint: Put you code in a pdf.

Hint: Put your code in a bitmap for screens *and* a PDF for printing.
That's the only way to guarantee that it'll work.

Since this is not possible, there is one solution left: Do not view
your code on screen, but only print it out. Then you can guarantee
that your columns are as you expected. Python could be enhanced to
take advantage of this; for instance, instead of requiring the hash
character (which may be difficult to type on certain keyboards,
including mobile phones), a letter C (U+0043) in column 1 can cause
the line to be considered a Comment.

ChrisA
 
N

Nicholas Cole

On Friday, 2 August 2013, Chris “Kwpolska” Warrick wrote:

[snip]
So, what are you feasting for? Nothing?


I have long since ceased to be amazed at the number of people who would
like their personal and arbitrary preferences, and the rationalisations
that go with them, to be validated and endorsed by others, in law if
possible and in policy documents if not!
 
W

wxjmfauth

Le samedi 3 août 2013 13:35:29 UTC+2, Nicholas a écrit :
On Friday, 2 August 2013, Chris “Kwpolska” Warrick wrote:


[snip]



So, what are you feasting for?  Nothing?


I have long since ceased to be amazed at the number of people who would like their personal and arbitrary preferences, and the rationalisations thatgo with them, to be validated and endorsed by others, in law if possibleand in policy documents if not!

----------

I have always found, computer scientists are funny scientists.


- They do love to solve the problems, they created themselves.

- They have the tendency to take the consequences as
the causalities.

- And they forget:

i) p => q <==> not(q) => not(p)

ii) To proof a law is correct, one has to proof it's correct
in all cases. To proof a law is incorrect, it is enough to
find one, and solelely one, case showing the law is incorrect.


In my computing experience, the "Python world" is really shining
on these points.

jmf
 
R

Roy Smith

I have always found, computer scientists are funny scientists.

I have always found that sciences which contain the word "science" in
their name tend to not be very scientific.

Biology, Chemistry, Physics, those are real sciences. Computer Science,
Social Science, Political Science, not so much.
 
C

Chris Angelico

I have always found that sciences which contain the word "science" in
their name tend to not be very scientific.

Biology, Chemistry, Physics, those are real sciences. Computer Science,
Social Science, Political Science, not so much.

Right. We use the scientific method only in our worst work, like
poking at a black-box system to try to reverse compile it. Our work
generally involves examining a problem and figuring out which set of
tools will best solve it, which is more of an engineering thing.
("Build a bridge. Your chasm is X meters across, your bridge must
support Y kg of vehicles traversing it, the terrain is unsuited to
pylons, and you must not exceed Z meters of height above the road
surface.") And programmers, like engineers, have to deal with the
possibility (or certainty) of idiots using their products. This is not
a pure science by any means.

ChrisA
 
S

Sergi Pasoev

What about Earth Science? But in this case, it is indeed science,
because in its name the word science is applied to the object of its
study. But in the case of "computer science", the word science is
applied to the word which describes the tool this "science" uses!! It's
like it was Telescope Science in the name of astronomy.
 
R

Roy Smith

Chris Angelico said:
programmers, like engineers, have to deal with the
possibility (or certainty) of idiots using their products.

As a programmer, I'm OK with the idea that idiots are using my programs.
What bothers me more is when, as a user of a program, I have to deal
with the fact that idiots wrote it.
 
C

Chris Angelico

As a programmer, I'm OK with the idea that idiots are using my programs.
What bothers me more is when, as a user of a program, I have to deal
with the fact that idiots wrote it.

Heh. Yeah. Too true.

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top