why no camelCase in PEP 8?

Roel Schroeven roel at roelschroeven.net
Thu May 28 16:44:13 EDT 2020


Peter J. Holzer schreef op 28/05/2020 om 22:09:
> On 2020-05-19 09:53:01 +0100, Rhodri James wrote:
>> On 18/05/2020 22:07, Eli the Bearded wrote:
>>> 	camelCase	->	 noCamelCase
>>> 	snake_case	->	 no_snake_case
>>>
>>> One of those is easier to "grep" for than the other.
>>
>> Eh.  A changed case in the one, an extra character in the other; that's
>> pretty much the same difficulty really.  I certainly don't find it "hard" to
>> grep for _snake_case.
> 
> I think you misunderstood his argument. He is saying that by searching
> for /snake_case/ you will find both "snake_case" and "no_snake_case".
> But /camelCase/ won't match "noCamelCase" - you have to search for
> /[cC]amelCase/ instead.
> 
> I'm not sure if I'm convinced by that. I prefer snake_case simply for
> aesthetic reasons. My native language is German, so I should be used to
> gratuitous capitalisation from early childhood - but I still find
> camelCase ugly.

For me, the reason for disliking camelCase is consistency. I don't like 
how in camelCase words are written differently just because they appear 
at the front or not at the front. I don't like that the c of camelCase 
changes to the C in noCamelCase; not for the easy of searching (though 
that is an argument, just not the one that irks me most) but because 
it's not consistent. Things should change when their meaning changes, 
not when their place changes.

Both PascalCase and snake_case don't have that inconsistency, which is 
why I like them a lot better than camelCase.

There's another reason why I don't like camelCase: it smells like Java, 
and I don't like Java. That's an entirely irrational feeling though, of 
course.

-- 
"Honest criticism is hard to take, particularly from a relative, a
friend, an acquaintance, or a stranger."
         -- Franklin P. Jones

Roel Schroeven



More information about the Python-list mailing list