coding conventions, PEP vs. practice

Discussion in 'Python' started by Roman Roelofsen, Jan 5, 2005.

  1. 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
    Roman Roelofsen, Jan 5, 2005
    #1
    1. Advertising

  2. Roman Roelofsen

    Roy Smith Guest

    Roman Roelofsen <> 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.
    Roy Smith, Jan 5, 2005
    #2
    1. Advertising

  3. Roman Roelofsen

    Robert Kern Guest

    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


    "In the fields of hell where the grass grows high
    Are the graves of dreams allowed to die."
    -- Richard Harter
    Robert Kern, Jan 5, 2005
    #3
  4. Roman Roelofsen

    Terry Reedy Guest

    "Robert Kern" <> wrote in message
    news:crff5d$noi$...
    > 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
    Terry Reedy, Jan 5, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrea Williams

    Coding Conventions for C#

    Andrea Williams, Feb 25, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    3,462
    Dennis
    Mar 5, 2004
  2. Tom Anderson
    Replies:
    24
    Views:
    4,760
    Peter Flynn
    May 19, 2009
  3. Joe Kesselman
    Replies:
    0
    Views:
    623
    Joe Kesselman
    May 11, 2009
  4. Peter Flynn
    Replies:
    0
    Views:
    646
    Peter Flynn
    May 13, 2009
  5. Tim Johnson

    PEP for module naming conventions

    Tim Johnson, Mar 11, 2011, in forum: Python
    Replies:
    3
    Views:
    510
    Jonathan Gossage
    Mar 17, 2011
Loading...

Share This Page