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

Abe Dillon abedillon at gmail.com
Wed Jan 30 18:24:38 EST 2019


[Steven D'Aprano]

> I've just watched it, ... it is a great video.


I'm really glad you did. I don't think many have, which I can't really
blame anyone for because it's rather long, but if all this thread
accomplishes is a few more people seeing that video, it'll have been worth
it.

[Steven D'Aprano]

> I don't agree with everything he says, but even where I disagree it is
> great food for thought.


Yes, I disagree about his anti-dependency-injection stance.

[Steven D'Aprano]

> IDEs rot the brain.


He advocates for the use of "extract method" only 12 minutes into the talk.
This comes off as Socrates famous warning that written language would, "create
forgetfulness in the learners’ souls, because they will not use their
memories.” No, IDEs are tools. Tools are generally meant to solve problems.
He laments that IDEs can encourage pointless boilerplate, but tools don't
have to include "the ghost of Clippy".

I know this is a jab at my suggestion that an IDE could help communicate
what is global (which, yes; is not synonymous w/ constant, though it
usually should be) via syntax highlighting. I wonder if you believe that
syntax highlighting "rots the brain"?

[Steven D'Aprano]

> the speaker makes an excellent point that in Java, you don't need a naming
> convention for constants
> because the compiler will give an error if you try to write to a constant.


That's not the only argument he makes against all caps constants, though I
agree that it's the strongest argument
against all caps in Java.

I largely agree with the rest of your post. I just don't think we need a
naming convention for constants.

On Fri, Jan 4, 2019 at 10:21 PM Steven D'Aprano <steve at pearwood.info> wrote:

> On Fri, Jan 04, 2019 at 01:01:51PM -0600, Abe Dillon wrote:
>
> > I keep coming back to this great video <https://vimeo.com/74316116>
>
> I've just watched it, its a bit slow to start but I agree with Abe that
> it is a great video. (And not just because the speaker agrees with me
> about 80 columns :-)
>
> I don't agree with everything he says, but even where I disagree it is
> great food for thought. I *strongly* suggest people watch the video,
> although you might find (as I did) that the main lessons of it are
> that many common Java idioms exist to work around poor language design,
> and that IDEs rot the brain.
>
> *semi-wink*
>
> Coming back to the ALLCAPS question, the speaker makes an excellent
> point that in Java, you don't need a naming convention for constants
> because the compiler will give an error if you try to write to a
> constant.
>
> But we don't have that in Python. Even if you run a linter that will
> warn on rebinding of constants, you still need a way to tell the linter
> that it is a constant.
>
> The speaker also points out that in programming, we only have a very few
> mechanisms for communicating the meaning of our code:
>
> - names;
> - code structure;
> - spacing (indentation, grouping).
>
> Code structure is set by the language and there's not much we can do
> about it (unless you're using a language like FORTH where you can create
> your own flow control structures). So in practice we only have naming
> and spacing.
>
> That's an excellent point, but he has missed one more:
>
> * naming conventions.
>
> In Python, we use leading and trailing underscores to give strong hints
> about usage:
>
>     _spam     # private implementation detail
>
>     __spam    # same, but with name mangling
>
>     __spam__  # overload an operator or other special meaning
>
>     spam_     # avoid name clashes with builtins
>
> We typically use CamelCase for classes, making it easy to distinguish
> classes from instances, modules and functions.
>
> And we use ALLCAPS for constants. If that's not needed in Java (I have
> my doubts...) we should also remember the speaker's very good advice
> that just because something is needed (or not needed) in language X,
> doesn't mean that language Y should copy it.
>
>
> --
> Steve
> _______________________________________________
> 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/5aa0dd55/attachment.html>


More information about the Python-ideas mailing list