[Python-Dev] PEP 8 updates/clarifications, function/method style
Brett Cannon
bcannon at gmail.com
Wed Dec 14 22:25:35 CET 2005
On 12/14/05, Michael Chermside <mcherm at mcherm.com> wrote:
> Guido writes:
> > Actually this (function, method and ivar names) is such a contentious
> > issue that I think the style guide should explicitly allow all
> > two/three styles and recommend to be consistent within a class, module
> > or package.
>
> Hurray! Now I can go back to using capWords for functions, methods, and
> variables!
>
> Guido writes:
> > Too late. I don't think the diversity is all that distracting.
>
> I disagree. One of the things that Java got very much right was to
> specify, from the very beginning, what the preferred conventions are
> for naming conventions. (Packages in lowercase, Classes in CapWords,
> methods and variables in lowerCapWords, constants optionally in
> ALL_CAPS. Abbrevs avoided, acronyms have all letters capitalized, eg:
> SimpleHTTPServer.)
>
> The conventions are nearly universally followed, and as a result in
> java I always know how to spell things. I never have to remember
> whether it's myDict.hasKey() and myDict.popitem() or myDict.has_key()
> and myDict.popItem(). Haskell goes too far -- they REQUIRE a certain
> convention as part of the language... this prevents breaking the rules
> on purpose (eg: wrapping a library from another language, or using
> an object with attributes to represent an XML node with child nodes).
I agree completely with this. I might remember the name of a method,
but I don't always remember the capping and the possible use of
underscores. Consistency would be really nice. I am not saying we
should rename everything (at least not until Python 3 =), but at
least we can make sure new stuff that is not preexisting can use a
consistent naming scheme.
And as for it being contentious, I say Guido can pronounce on this.
We are all grown-ups and can learn to name things in a certain way to
give our memories an easier time. =)
-Brett
More information about the Python-Dev
mailing list