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

Roy Smith roy at panix.com
Mon May 28 10:50:54 EDT 2007


In article <KaedndQFOP7OucTbnZ2dnUVZ_hisnZ2d at comcast.com>,
 Steven Bethard <steven.bethard at gmail.com> wrote:

> 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 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.
> 
> The argument for under_score_names is usually that non-native speakers 
> can more easily find the word boundaries. Not being a non-native speaker 
> ;-) I can't verify that one, but it's pretty plausible given the current 
> amount of money spent on research on automatic word-segmentation for 
> languages like Chinese. =)
> 
> STeVe

I've gone through a few different flavors of composite name schemes over 
the years (starting with FORTRAN's 6 upper case character limit).  When 
first exposed to camelCase, I thought it was horrible.  Eventually, I came 
to like it.

On the other hand, I'm convinced that words_with_underscores, is easier to 
read.  This is especially true when abbreviations creep into variable 
names.  It's certainly easier to parse ip_address as compared to IPAddress.  
Same with snmp_manager vs SNMPManager.

I really like lisp's convention of using dashes instead of underscores, 
i.e. ip-address and snmp-manager.  I think the only reason most languages 
don't use that is the parsing ambiguity, but if you required white space 
around all operators, then "ip-address" would unambiguously be a variable 
name and "ip - address" would be a subtraction expression.



More information about the Python-list mailing list