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

Abe Dillon abedillon at gmail.com
Fri Jan 4 21:11:44 EST 2019


>
> All-caps does *not* signify "don't override this".

PEP-8 specifically says to use all caps to signify constants. What exactly
do you think the word "constant" means? I know very well Python doesn't
support actual constants and that anything can be overridden.

Your example goes against the convention of using all caps to signify
constants and it's a bad design all around. You would be better off with:

def get_emote_lits(root = os.path.normpath(__file__ + "/../emotes")): ... #
congratulations, you've re-invented the default parameter in a more clunky
way! I don't know many APIs built around having you fiddle with
module-level variables, it seems like an anti-pattern to me.
>
> If "don't change this externally" is the default, why would we have a
> naming convention meaning "don't change this externally"?

Modules and Classes and functions typically expose functionality while the
purpose of most other objects is to encapsulate state,
so it makes sense that attributes would be read/write by default, though
some even disagree on that point. I'm not a hard-core functional
programming fanatic, so I'm not about to argue that everything should be
read-only by default.
I also think you're playing dumb to avoid confronting my point: If you
found that there was an undocumented module-level attribute in pandas, what
would be your initial assumption? If it's not all caps, is it fair game to
override it? Can you re-write your emote code so that it's clear that the
emote-path variable is part of the API *without* any documentation? How
much does all caps really communicate?

On Fri, Jan 4, 2019 at 7:16 PM Chris Angelico <rosuav at gmail.com> wrote:

> On Sat, Jan 5, 2019 at 11:58 AM Abe Dillon <abedillon at gmail.com> wrote:
> > You made EMOTE_PATH all caps signifying it's a constant, then added a
> comment saying that it "Can be overwritten prior to calling get_emote_list".
> >
> > So not only was your naming convention, on its own, insufficient to
> explain the API of your code, but you're completely violating PEP-8 because
> your using the constancy convention on something that's not constant.
> That's 100% counterintuitive. You subvert the one thing that all-caps is
> supposed to communicate.
> >
>
> If "don't change this externally" is the default, why would we have a
> naming convention meaning "don't change this externally"? I think
> you're misunderstanding the way that module constants are used in
> Python. They CAN be overridden. That is part of the point. All-caps
> does *not* signify "don't override this".
>
> 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/20190104/8cb913a9/attachment.html>


More information about the Python-ideas mailing list