why objects of old style classes are instances of 'object'

A

AlFire

Hi,

Q: from the subject, why objects of old style classes are instances of
'object'?

True



I would expect False


Thx,
Andy
 
D

Diez B. Roggisch

AlFire said:
Hi,

Q: from the subject, why objects of old style classes are instances of
'object'?


True

Because everything is an object.

But not everything is a newstyle-class:


Diez
 
A

AlFire

Diez said:
But not everything is a newstyle-class:


thx for explanation. but more I look at it less and less I like the
notation of new-style-class definition. what is an added value of adding
"(object)" since it is already an object. Any insight?

Note: I am not a language purist, more a pragmatic who like a good style.

Andy
 
G

Gabriel Genellina

En Tue, 22 Apr 2008 00:49:27 -0300, AlFire
thx for explanation. but more I look at it less and less I like the
notation of new-style-class definition. what is an added value of adding
"(object)" since it is already an object. Any insight?

Read Diez previous post again.
An old-style class is an *instance* of object (as all other objects), but
not a *subclass* of object. It does not *inherit* from object.
A new-style class is both an instance of object and a subclass of object.
It inherits from object. This is what the base (object) means.
Note: I am not a language purist, more a pragmatic who like a good style.

We need *some* way to distinguish new-style classes from old ones. The
(object) base is simple, doesn't require new syntax, and it's true (hmm,
this may be a form of petitio principii)
In Python 3.0, old-style classes are gone, and the (object) is not
necesary: all classes inherit from object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top