ten small Python programs

Steven Bethard steven.bethard at gmail.com
Sat May 26 22:33:04 EDT 2007


Paul McGuire wrote:
> I ***love*** this "10 Little Programs" idea!  As soon as I get a
> breathing space, I'm going to add a "10 Little Parsers" page to the
> pyparsing wiki!
> 
> On May 26, 2:38 pm, Steven Bethard <steven.beth... at gmail.com> wrote:
>> <nitpick>
>> Though the code should probably follow PEP 8 guidelines, e.g.
>> under_scores instead of camelCase for object and method names:
>>
>>      http://www.python.org/dev/peps/pep-0008/
>> </nitpick>
> 
> Really?  Underscore-separated words preferred over camel case?  What
> is the rationale for this?

Rationale?  It's a style guide.  There is no rationale. ;-)

> If we want to just say "well, PEP-8 says such and such," I think this
> is an area where the thinking has possibly evolved since 2001.

I really don't think so. If anything, it's gotten more strict. PEP 8 
used to allow either camelCase or under_scores. Now it only allows the 
latter.

> I guess pyparsing with its mixedCase functions and attributes is
> doomed for the Dunce Corner.  Too bad for BeautifulSoup, cElementTree,
> and wxPython that are also at variance with this canon of Python
> coding style.

Many (if not all) of these modules were written before the most recent 
incarnation of PEP 8. Thus, they fall under the second good reason "to 
break a particular rule":

     (2) To be consistent with surrounding code that also breaks it

Of course, for new code, such as that in this thread, there's no reason 
to break from the PEP 8 guidelines.


STeVe



More information about the Python-list mailing list