[Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS

Abe Dillon abedillon at gmail.com
Wed Jan 30 17:41:08 EST 2019


[ChrisA]

> Nobody is saying that the *entire document* should be in all caps.


I've never claimed as much. Most of the reasons all caps harm readability
hold true whether you're talking about a single word or entire document.

[ChrisA]

> Are English paragraphs hard to read because tokens like "HTML" and "IBM"
> are in all-caps?


Acronyms are a different use case for all caps. We can discuss the value
proposition for those in another thread if you'd like.
I will say that I read my share of research papers where acronyms tend to
see heavy use and, yes; it can harm readability.

[ChrisA]

> With constants that are taken directly from C, consistency is
> extremely helpful.


That's fair. I can live with it. The socket module was just an example.
There are several examples of all caps that aren't inherited from other
sources.

If datetime.MINYEAR and datetime.MAXYEAR were datetime.minyear and
datetime.maxyear what do you think the consequences would be?
Do you really think it's less clear?
Do you think timedelta.min, timedelta.max, and timedelta.resolution aren't
clear enough? How about string.digits? Should those shout at you that
they're constants? Why or why not?

[ChrisA]

> Are you going to appeal to Google to have *their* style guide changed too?


That's comparing apples and oranges. Python is an open language with an
ideas forum about how to improve things. Google generally isn't open to my
suggestions. Any given company I work with is much more likely to enforce
PEP-8 than Google's style guides. As far as I know, getting Google to adopt
a given idea isn't a precondition for the Python community accepting said
idea.

[ChrisA]

> treat PEP 8 as a guideline


Again, that's not always an option.

On Wed, Jan 30, 2019 at 3:41 PM Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Jan 31, 2019 at 8:23 AM Abe Dillon <abedillon at gmail.com> wrote:
> >
> > > Capitalizing constants may be slightly harder to read but constants in
> code are the minority and emphasizing them is precisely the point.
> >
> > The question I'm trying to get everyone to actually think about:
> >
> > Is the communication of constancy via ALL CAPS so important that it must
> be in PEP-8 despite the documented harm that all caps does to readability?
> >
> > ttps://
> www.mity.com.au/blog/writing-readable-content-and-why-all-caps-is-so-hard-to-read
> > https://en.wikipedia.org/wiki/All_caps#Readability
> > https://uxmovement.com/content/all-caps-hard-for-users-to-read/
> > https://practicaltypography.com/all-caps.html
>
> Nobody is saying that the *entire document* should be in all caps.
> This is a specific token, a specific identifier. Are English
> paragraphs hard to read because tokens like "HTML" and "IBM" are in
> all-caps?
>
> > If socket.AF_INET6 were socket.af_inet6 would you consider re-binding
> that variable? Would you be worried that other code will re-bind it? Can
> you measure the value of the information conveyed by all-caps? Are you so
> sure that it's as important as you think?
> >
>
> With constants that are taken directly from C, consistency is
> extremely helpful. Why is it called AF_INET6? Because it has exactly
> the same as AF_INET6 in C, or any other language that also has derived
> its socket handling from BSD sockets. (Which, for reference, is
> basically every language that has any sort of socket support.)
>
> > I've gotten a lot of responses like, "If you don't like it just ignore
> PEP-8, it's not mandatory".
> > A) It is mandatory in many cases.
>
> That is not PEP 8's problem. The document stipulates that it is the
> standard for the Python standard library, nothing else. Are you going
> to appeal to Google to have *their* style guide changed too? A lot of
> people have adopted Google's style guide, and it explicitly says that
> module level constants *must* be in all caps.
>
> > B) We could just as easily NOT prescribe all caps in PEP-8 but still
> allow it. In other words: you can use all caps if you want to but it's not
> mandatory or in PEP-8. I would like to discourage its use, but we don't
> have to go so far. That way nobody has to violate PEP-8.
> >
>
> I don't think PEP 8 actually mandates that *all* constants be written
> in all caps. It says "usually". But you have many options here -
> ignore PEP 8, treat PEP 8 as a guideline, or just accept that
> ALL_CAPS_CONSTANTS actually do carry useful information in their
> names.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190130/7b232133/attachment.html>


More information about the Python-ideas mailing list