coding conventions, PEP vs. practice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roman Roelofsen

    #1

    coding conventions, PEP vs. practice


    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_wit h_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

  • Roy Smith

    #2
    Re: coding conventions, PEP vs. practice

    Roman Roelofsen <r.roelofsen@tu xed.de> wrote:[color=blue]
    > These frameworks are using "mixedCase" but PEP8 suggests
    > "lower_case_wit h_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.[/color]

    My personal preference is camelCase over words_with_unde rscores, 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.

    Comment

    • Robert Kern

      #3
      Re: coding conventions, PEP vs. practice

      Roman Roelofsen wrote:[color=blue]
      > 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.[/color]

      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
      rkern@ucsd.edu

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

      Comment

      • Terry Reedy

        #4
        Re: coding conventions, PEP vs. practice


        "Robert Kern" <rkern@ucsd.edu > wrote in message
        news:crff5d$noi $1@news1.ucsd.e du...[color=blue]
        > 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."[/color]

        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





        Comment

        Working...