Sergio Correia a écrit :
> 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?

Because it is an exception ?-)

Notice that all builtin types (list, dict, set, str, unicode, int, long, 
float, tuple, file, object, type, function, classmethod, staticmethod, 
property etc) are lower-case.

(snip interrogations about "object"'s type)

>>>> class Eggs(object):
>       def __init__(self):
>               self.x = 1
>>>> type(Eggs)
> <type 'type'>
> 
> Type 'type'? What is that supposed to mean?

type(Eggs) is roughly equivalent to Eggs.__class__, ie it returns the 
class of the Eggs class object, IOW the metaclass. In Python, classes 
are objects, so they are themselves instances of a class - by default, 
for new-style classes, instances of the class 'type'. In case you 
wonder, class 'type' is an instance of itself.


> Hope this makes any sense ;),

Idem !-)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to