On Wed, May 7, 2008 at 7:40 PM, Yves Dorfsman <[EMAIL PROTECTED]> wrote:
> Does it make a difference if you put subclass object or not ?
>
>  What is the difference between c1 and c2 here:
>
>  class c1:
>   pass
>
>  class c2(object):
>   pass

>>> type(c1)
<type 'classobj'>
>>> type(c1())
<type 'instance'>
>>> type(c2)
<type 'type'>
>>> type(c2())
<class '__main__.c2'>

In Python 2.2, classes and types were unified.  If a class inherits
from object (or any other built-in), it is considered a "new-style"
class; otherwise, it is an old-style (or classic) class.  There are
some differences in their behavior; most notably, descriptors
(computer properties) will not work with old-style classes.  Old-style
classes will go away in Python 3 (I think), and all classes will have
object as a base.

An introduction to new-style classes:
http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html
A guide to descriptors:
http://users.rcn.com/python/download/Descriptor.htm
The reference manual on the distinction:
http://docs.python.org/ref/node33.html
The technical explanation:
http://www.python.org/download/releases/2.2.3/descrintro/

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

Reply via email to