why no camelCase in PEP 8?

Eli the Bearded * at eli.users.panix.com
Mon May 18 17:07:30 EDT 2020


In comp.lang.python, Paul Rubin  <no.email at nospam.invalid> wrote:
> I don't know if this was the explicit motivation for PEP 8, but it
> has always seemed valid to me:
> 
> https://en.wikipedia.org/wiki/Camel_case#Readability_studies

There are three things cited there. One is a NYTimes story from 2009
"Against Camel Case" starting out with criticism of "iPhone" which
the author describes but won't use as it it too difiguring. That's not a
programmer talking about program identifiers.

The other two are more relevant, two studies one from 2009 and one from
2010, each of which seems to reach a conclusion at odds with the other.
The 2009 one finds camelCase easier to read than snake_case, and the
2010 one finds people recognize snake_case identifiers faster than
camelCase ones. I don't think that Wikipedia page helps your case.

I personally abhor the use of inappropriate mid-word caps in English,
which fits the NYT piece, but am only mildly against them in code. I had
some bad expierences with code that forced use of capital letters in
college and that has tainted me against excess capitals ever since. This
is a highly personal reason that I don't expect anyone else to share.

Here's a simple argument against camel case: when it becomes necessary
to join identifiers, camel case requires modification of the original
unit while snake case just adds stuff to beginning and/or end. One
noteworthy example is when a negated version is needed.

	camelCase	->	 noCamelCase
	snake_case	->	 no_snake_case

One of those is easier to "grep" for than the other.

Elijah
------
grep-ability of code should on everyone's mond


More information about the Python-list mailing list