[Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS
rosuav at gmail.com
Wed Jan 30 16:40:23 EST 2019
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?
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
> 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
More information about the Python-ideas