On Fri, 2007-09-07 at 01:30 -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?
The convention is that classes written in C use lower case, while classes written in Python use capital letters. That's why list, tuple, set, dict, and so forth are all classes with lower case letters. > 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? I'm not 100% sure how new style classes work, but my understanding is that while normally we refer to objects as instances of classes, classes are really instances of type objects! Types are treated specially (IIRC, types are instantiated exactly once, on the stack) in Python, so you shouldn't worry about them, other than to know they are the "class" that classes belong to. -- Evan Klitzke <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list