Why 'class spam(object)' instead of class spam(Object)' ?

Carl Banks pavlovevidence at gmail.com
Fri Sep 7 04:02:45 EDT 2007


On Fri, 07 Sep 2007 01:30:00 -0500, Sergio Correia wrote:
> Hi, I'm kinda new to Python (that means, I'm a total noob here), but
> have one doubt which is more about consistency that anything else.
> 
> Why if PEP 8 says that "Almost without exception, class names use the
> CapWords convention", does the most basic class, object, is lowercase?

It said "almost".  :)


> I found a thread about this:
> http://mail.python.org/pipermail/python-list/2007-April/437365.html
> where its stated that -object- is actually a type, not a class; but the
> idea still doesn't convince me.

There's a false dichotomy there: it's not an either-or situation.  Almost 
everyone would agree that new-style classes, defined by the Python class 
statement, are both classes and types.  Some might squabble over whether 
object is class, but it has nothing to do with why object is spelled in 
lower-case.

The reason why "object" is lower case is because built-in types are 
spelled in lower-case.  Why are built-in types lower case?  Because many 
built-in types were originially functions.  For example, "int" and "str" 
were once functions.  When these symbols became the names of their 
respective types, they kept the lower-case spelling, and it became 
convention for built-in types to be spelled lower-case.


Carl Banks



More information about the Python-list mailing list