Yet Another Case Question

Alex Martelli aleax at
Mon Feb 24 15:27:01 CET 2003

rzed wrote:
> important to some of us. Three conventions come to mind: the use of
> ALLCAPS for constants; the use of InitialCaps for class names; and the
> use of initialLowerCase for instance and method names.
> benefit is that it enforces a common coding convention.

Case sensitivity does NOT enforce the common coding convention
you seem to like so much.  Don't you think math.pi IS a constant?
Yet it's not in ALLCAPS, isn't it?  What about class async_chat
in module asynchat?  Isn't it a class?  So where are its InitialCaps?
And what about function AudioDev in module audiodev -- it's a
function, yet, where is its initialLowerCase...?  We can go on
finding examples for hours even just withing the Python standard
library, so what "enforcement" are you TALKING about?!

Now, you can claim all of the Python standard library is coded so
terribly it should just be junked; or you can claim the convention
is really a very minor thing whose violations are immaterial; it's
up to you.  What's indisputable is: the convention is NOT enforced
and indeed it's often violated even within the standard library;
and case-sensitivity doesn't even let you MAKE BELIEVE that this
convention actually holds, by referring to math.PI and so on (well,
unless with considerable trouble -- assigning all the convention
respecting identifiers in the various stdandard library modules;-).

What case sensitivity DOES do is force every user to memorize all
of the idiosyncratic "conventions" the many modules in the Python
standard library follow (or don't), unless they want to go at it
by trial and error, introspection, or compulsive docreading.  You
can't just say "here I'll just call the audiodev function of the
same-name module" (etc) -- you have to memorize that, in a totally
arbitrary way, the module name MUST be all-lowercase but the name
of the function has a capital letter at the start and another one
in the middle.  What DOES get enforced is a random collection of
idiosyncrasies such as these.

You want case-sensitivity ENFORCING a capitalization convention?
Haskell has it, I believe -- try naming a typeclass without a
leading capital letter, or a function with a capital letter, and
the compiler will snarl at you.  I don't like it, but I can see
it DOES make some sense, particularly in a language that is very
particular about static typing.  But Python's current treatment
of case is neither fish nor fowl -- and it will never become
either, I think... it will never actually enforce the convention
(and it would be a disaster if it ever did, hampering dynamic
polymorphism between classes and functions that often works so
well, for example) and won't even let anybody (without the huge
effort of rebinding lots of names in the standard library;-)
*MAKE BELIEVE* the convention actually holds.  I fail to see the
motivations to keep defending this sad state of affairs, most
particularly to do so with false claims about "enforcing
conventions" that aren't actually encforced by it.  Why not just
accept that it's just a wart that will never go away?


More information about the Python-list mailing list