Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > coding conventions, PEP vs. practice

Reply
Thread Tools

coding conventions, PEP vs. practice

 
 
Roman Roelofsen
Guest
Posts: n/a
 
      01-05-2005

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

 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      01-05-2005
Roman Roelofsen <(E-Mail Removed)> wrote:
> 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.
 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      01-05-2005
Roman Roelofsen wrote:
> 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
http://www.velocityreviews.com/forums/(E-Mail Removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      01-05-2005

"Robert Kern" <(E-Mail Removed)> wrote in message
news:crff5d$noi$(E-Mail Removed)...
> 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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PEP 8: Byte Order Mark (BOM) vs coding cookie twyk Python 2 08-25-2008 03:59 AM
About Rational Number (PEP 239/PEP 240) Lie Python 25 12-18-2007 06:13 AM
general coding issues - coding style... calmar Python 11 02-21-2006 10:36 AM
Remember when your piano teacher taught you, "Practice, practice,practice ...?" Wayne Wastier Windows 64bit 3 06-10-2005 08:29 PM
PEP for new modules (I read PEP 2) Christoph Becker-Freyseng Python 3 01-16-2004 04:26 PM



Advertisments