[Python-Dev] pep8 reasoning

Tim Peters tim.peters at gmail.com
Thu Apr 24 18:36:03 CEST 2014


There's been a bit of serious study on this.  The results are still
open to interpretation, though ;-)  Here's a nice summary:

http://whathecode.wordpress.com/2011/02/10/camelcase-vs-underscores-scientific-showdown/

of-course-dashes-are-most-natural-ly y'rs  - tim

On Thu, Apr 24, 2014 at 11:25 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, Apr 24, 2014 at 11:59 PM, Barry Warsaw <barry at python.org> wrote:
>> I will say this: the original preference for underscore_names in PEP 8 was
>> spurred by user studies some of our early non-native English speaking users
>> conducted many years ago.  We learned that it was more difficult for many of
>> them to parse mixedCase names than underscore_names.  I'm afraid I probably no
>> longer have references to those studies, but the difference was pronounced,
>> IIRC, and I think it's easy to see why.  Underscores can be scanned by the eye
>> as spaces, while I'd hypothesize that the brain has to do more work to read
>> mixedCase names.
>
> Underscores also play much more nicely with initialisms. How would you
> spell a function named "Add HTTP Header"?
>
> add_HTTP_header
> add_http_header
>
> addHTTPHeader
> addHttpHeader
>
> Four options to choose from. The first two clearly separate the
> initialism from the other words; take your pick whether you want it
> uppercased or not, because it's separated either way. In mixedCase,
> the first one merges the H of Header in with HTTP; with something less
> well known, that can be a nasty readability problem. The second one is
> probably more readable, but looks weird. Or, here's another one:
> converting one thing into another, where both are named by their
> initials:
>
> convert_XML_to_JSON
> convert_xml_to_json
>
> convertXMLToJSON
> convertXmlToJson
>
> Same four options. Which is the more readable?
>
> ChrisA
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/tim.peters%40gmail.com


More information about the Python-Dev mailing list