Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Do we still need to inherit from "object" to create new-style classes?

Reply
Thread Tools

Do we still need to inherit from "object" to create new-style classes?

 
 
John Salerno
Guest
Posts: n/a
 
      06-21-2011
I can't quite seem to find the answer to this anywhere. The book I'm
reading right now was written for Python 3.1 and doesn't use (object),
so I'm thinking that was just a way to force new-style classes in 2.x
and is no longer necessary in 3.x. Is that right?

(The documentation doesn't mention object anymore, but elsewhere on
the Python website it says the documentation hasn't been updated for
new-style classes yet, hence my confusion.)

Thanks.
 
Reply With Quote
 
 
 
 
Benjamin Kaplan
Guest
Posts: n/a
 
      06-21-2011
On Mon, Jun 20, 2011 at 6:26 PM, John Salerno <> wrote:
> I can't quite seem to find the answer to this anywhere. The book I'm
> reading right now was written for Python 3.1 and doesn't use (object),
> so I'm thinking that was just a way to force new-style classes in 2.x
> and is no longer necessary in 3.x. Is that right?
>
> (The documentation doesn't mention object anymore, but elsewhere on
> the Python website it says the documentation hasn't been updated for
> new-style classes yet, hence my confusion.)
>
> Thanks.


3.x got rid of old-style classes altogether, so you are correct-
there's no need to explicitly subclass object.
 
Reply With Quote
 
 
 
 
John Salerno
Guest
Posts: n/a
 
      06-21-2011
On Jun 20, 8:33*pm, Benjamin Kaplan <benjamin.kap...@case.edu> wrote:
> On Mon, Jun 20, 2011 at 6:26 PM, John Salerno <johnj...@gmail.com> wrote:
> > I can't quite seem to find the answer to this anywhere. The book I'm
> > reading right now was written for Python 3.1 and doesn't use (object),
> > so I'm thinking that was just a way to force new-style classes in 2.x
> > and is no longer necessary in 3.x. Is that right?

>
> > (The documentation doesn't mention object anymore, but elsewhere on
> > the Python website it says the documentation hasn't been updated for
> > new-style classes yet, hence my confusion.)

>
> > Thanks.

>
> 3.x got rid of old-style classes altogether, so you are correct-
> there's no need to explicitly subclass object.


Thanks! And apologies for having to start a thread to ask just that!
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      06-21-2011
On 6/20/2011 9:26 PM, John Salerno wrote:
> I can't quite seem to find the answer to this anywhere. The book I'm
> reading right now was written for Python 3.1 and doesn't use (object),
> so I'm thinking that was just a way to force new-style classes in 2.x
> and is no longer necessary in 3.x. Is that right?
>
> (The documentation doesn't mention object anymore,


Lib ref 2. builtin functions:
"object()
Return a new featureless object. object is a base for all classes. It
has the methods that are common to all instances of Python classes. This
function does not accept any arguments.

Note
object does not have a __dict__, so you can’t assign arbitrary
attributes to an instance of the object class.
"

> but elsewhere on
> the Python website it says the documentation hasn't been updated for
> new-style classes yet, hence my confusion.)


What page? *It* may need updating .

The core 3.x docs have been updated by removing all reference to
old-style classes and the modifier 'new-style'. The concept 'new-style'
only exists in opposition to 'old-style'. 3.x just has classes, and all
are subclasses of object.

--
Terry Jan Reedy


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need to lookup master interface that inherit IP address to unnumbered interface via SNMP tua Cisco 0 10-30-2007 12:30 PM
inherit from file and create stdout instance? MisterPete Python 7 05-16-2007 03:22 AM
Mozilla: Can I still keep IE and outlook? Or still vulnerable to viruses? lbbss Computer Support 6 08-16-2004 11:55 PM
inherit DataColumnCollection Frank ASP .Net 0 07-08-2003 09:40 PM
How to inherit a base form in all application forms of an asp.net application varun varun ASP .Net 0 07-03-2003 08:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57