why no camelCase in PEP 8?
Peter J. Holzer
hjp-python at hjp.at
Thu May 28 18:25:53 EDT 2020
On 2020-05-29 06:27:31 +1000, Chris Angelico wrote:
> On Fri, May 29, 2020 at 6:20 AM Peter J. Holzer <hjp-python at hjp.at> wrote:
> > On 2020-05-19 05:59:30 +1000, Chris Angelico wrote:
> > > PEP 8 is a style guide for the Python standard library. It is the
> > > rules you must comply with if you are submitting a patch *to Python
> > > itself*. Nobody ever requires you to comply with it for any other
> > > code.
> >
> > That's obviously not true: Many companies and projects have a coding
> > standard. Many of those coding standards will be based on or even
> > identical to PEP 8. And as an employee or contributor you may be
> > required to comply with it. Now you might argue that in this case you
> > aren't required to comply with PEP 8, but with the coding standard of
> > your company, but I would consider that excessive nitpickery.
> >
>
> The OP said:
> > My preference for using camelCase (in PEP 8, AKA mixedCase) is
> > putting me at odds with my colleagues, who point to PEP 8 as "the
> > rules".
> >
>
> This smells like the incredibly strong misconception that PEP 8 needs
> to govern every line of Python code ever written, or else it's "bad
> code". This thread wouldn't have been started if it had been any other
> style guide that the company had been chosen, because then it's
> obvious that the choice is the company's. It's only when PEP 8 is
> considered to be some sort of universal standard that we get this kind
> of discussion.
It may be the case in this specific instance (although I don't know, as
I don't work for the OP's company and don't know his colleagues). I
don't think it is generally the case.
When a company introduces a coding standard, I think "just use PEP 8" is
a very reasonable choice (it's not inherently better or worse than any
other style, but just by being familiar to a lot of Python programmers
it is likely to elicit less resistance and bike-shedding).
So this might lead to the following exchange during a code review:
A: Please don't use camelCase for variables. It's against our coding
style.
B: Why don't we allow camelCase for variables?
A: Because PEP 8 doesn't allow it.
B: Why doesn't PEP 8 allow it?
A: Uh, ask the PEP 8 authors.
At which point B becomes the OP of this thread.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp at hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20200529/788bf068/attachment.sig>
More information about the Python-list
mailing list