On Thu, Apr 24, 2014 at 11:59 PM, Barry Warsaw <ba...@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@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to