coding conventions, PEP vs. practice

  • Thread starter Roman Roelofsen
  • Start date
R

Roman Roelofsen

Dear python-list,

while looking for some coding conventions for python programs, i found the
PEP8 at http://www.python.org/peps/pep-0008.html. It defines the rules very
well and leaves no space for interpretations. I guess thats a good thing :)
But when i started playing a bit with python and frameworks like Zope,
Webworks, etc., i noticed, that a lot frameworks are using a different
convention for methodnames.

These frameworks are using "mixedCase" but PEP8 suggests
"lower_case_with_underscores" except "in contexts where that's already the
prevailing style" which is not the case here IMHO.

So, are there any specific reasons for breaking the rules here? I think
consistent conventions are very important. Being a Java developer in the last
couple of years, i learned how practical it can be to have only one naming
style.

Best regards,

Roman
 
R

Roy Smith

Roman Roelofsen said:
These frameworks are using "mixedCase" but PEP8 suggests
"lower_case_with_underscores" except "in contexts where that's already the
prevailing style" which is not the case here IMHO.

So, are there any specific reasons for breaking the rules here? I think
consistent conventions are very important. Being a Java developer in the last
couple of years, i learned how practical it can be to have only one naming
style.

My personal preference is camelCase over words_with_underscores, but
fundamentally, this is a bit of a religious issue. Pick a style, and go
with it.

If you're working on existing code, go with the prevailing style. If
you're working in a group, pick a common style and go with the group
decision. Of all the software engineering issues to worry about, this
is pretty low on the list.
 
R

Robert Kern

Roman said:
Dear python-list,

while looking for some coding conventions for python programs, i found the
PEP8 at http://www.python.org/peps/pep-0008.html. It defines the rules very
well and leaves no space for interpretations. I guess thats a good thing :)
But when i started playing a bit with python and frameworks like Zope,
Webworks, etc., i noticed, that a lot frameworks are using a different
convention for methodnames.

Note the first sentence of the PEP: "This document gives coding
conventions for the Python code comprising the standard library for the
main Python distribution."

It is not intended to be a style guide for all Python code although many
groups do adopt all or part of it for their own style guides.

--
Robert Kern
(e-mail address removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
T

Terry Reedy

Robert Kern said:
Note the first sentence of the PEP: "This document gives coding
conventions for the Python code comprising the standard library for the
main Python distribution."

Even that should say "from now on". Some library code was written before
PEP8. And Guido has so far discouraged purely stylistic patches to
functioning code (because of the risk on introducing bugs where none
exist).

TJR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top