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

Sergio Correia sergio.correia at gmail.com
Fri Sep 7 02:30:00 EDT 2007


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?

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.

If i create a class Spam using -object- as a parent class, I would
expect -object- to be a class, not a type as in type(object) (what is
the difference between both btw?). But, on the other hand, if I do
help(object), I get:

>>> help(object)
Help on class object in module __builtin__:

class object
 |  The most base type

So is this a class? No...

>>> object
<type 'object'>

My doubts get compounded when strange stuff starts to happen:

>>> class Eggs(object):
	def __init__(self):
		self.x = 1
>>> type(Eggs)
<type 'type'>

Type 'type'? What is that supposed to mean?

Hope this makes any sense ;),

Sergio



More information about the Python-list mailing list