[Python-Dev] pep8 reasoning

Daniel Holth dholth at gmail.com
Thu Apr 24 20:01:50 CEST 2014


Fortunately, Unicode provides us with the COMBINING LOW LINE
character, combining the horizontal space-savings of camelCase with
the underscore-indicates-separation properties of _. And it's a valid
Python identifier.

convertx̲mlt̲oj̲son



On Thu, Apr 24, 2014 at 12:25 PM, 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/dholth%40gmail.com


More information about the Python-Dev mailing list