Is PEP-8 a Code or More of a Guideline?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Sun May 27 14:18:31 EDT 2007


Stefan Sonnenberg-Carstens wrote:
> Paul McGuire schrieb:
> > I'm starting a new thread for this topic, so as not to hijack the one
> > started by Steve Howell's excellent post titled "ten small Python
> > programs".
> >
> > In that thread, there was a suggestion that these examples should
> > conform to PEP-8's style recommendations, including use of
> > lower_case_with_underscores style for function names.  I raised some
> > questions about this suggestion, since I liked the names the way they
> > were, but as a result, part of the discussion has drifted into a
> > separate track about PEP-8, and naming styles.
> >
> > I was under the impression that lower_case_with_underscores was a
> > dated recommendation, and that recent practice is more inclusive of
> > mixedCase style identifiers.  On the contrary, Steven Bethard
> > straightened me out, saying that PEP-8 used to accept either style,
> > but has been amended to accept only lower_case_with_underscores.
> >
> > My latest thought on the topic relates back to the Martin v. Lo:wis
> > thread-that-would-not-die requesting feedback about PEP 3131, on
> > adding support for non-ASCII identifiers in Py3K.  I posted an out-of-
> > curiosity comment asking about how underscore separators mix with
> > Unicode identifiers, including the mechanics of actually typing an
> > underscore on a non-US keyboard.  At this point, I realized that I was
> > taking things too far off-topic, so I decided to start a new thread.
> >
> > Steve, sorry for taking your thread down a rathole.  I hope we can
> > move any further PEP-8-related discussion (if the point merits any) to
> > this thread.
> >
> > -- Paul
> >
> >
> I prefer mixedCaseStyle, and I think that should be "standard", as this
> style is commonly
> used in all "major" languages , for example Java,C++,C#.
> It shortens the identifiers but leaves the meaning intact.

Actually, proper_case is standard in C++ (see, e.g., the naming
section of http://www.research.att.com/~bs/bs_faq2.html ) .  And C is
still more common than Java, and Perl and Lisp are about as common as
C#--all use proper case (though Lisp uses - instead of _).
Historically, it's only Java and the Windows world (including non-
standard Windows-style C++) that use forcedCase significantly (C#
draws from both).

The underscore version is not "lower case"; it is "proper case"--case
is used as in normal English.  Compare plot_line_slope() vs.
plot_line_Besenheim(); with the underscore method, you preserve all
the natural meaning of case.  Especially when you have, say, acronyms
in variable names, forcedCase can be somewhat confusing even for
native English speakers; the style forces you to use a specific case
for naming convention reasons, losing the natural meaning of the case.




More information about the Python-list mailing list