Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8049 > unrolled thread

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

Started byJohn Salerno <johnjsal@gmail.com>
First post2011-06-20 18:26 -0700
Last post2011-06-21 13:30 -0400
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Do we still need to inherit from "object" to create new-style classes? John Salerno <johnjsal@gmail.com> - 2011-06-20 18:26 -0700
    Re: Do we still need to inherit from "object" to create new-style classes? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-20 18:33 -0700
      Re: Do we still need to inherit from "object" to create new-style classes? John Salerno <johnjsal@gmail.com> - 2011-06-20 19:13 -0700
    Re: Do we still need to inherit from "object" to create new-style classes? Ben Finney <ben+python@benfinney.id.au> - 2011-06-21 12:41 +1000
    Re: Do we still need to inherit from "object" to create new-style classes? Terry Reedy <tjreedy@udel.edu> - 2011-06-21 13:30 -0400

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

FromJohn Salerno <johnjsal@gmail.com>
Date2011-06-20 18:26 -0700
SubjectDo we still need to inherit from "object" to create new-style classes?
Message-ID<a99ab9f2-dfde-4107-a26d-7720bf6bf6d8@f7g2000yqf.googlegroups.com>
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.

[toc] | [next] | [standalone]


#8050

FromBenjamin Kaplan <benjamin.kaplan@case.edu>
Date2011-06-20 18:33 -0700
Message-ID<mailman.206.1308620023.1164.python-list@python.org>
In reply to#8049
On Mon, Jun 20, 2011 at 6:26 PM, John Salerno <johnjsal@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.

[toc] | [prev] | [next] | [standalone]


#8055

FromJohn Salerno <johnjsal@gmail.com>
Date2011-06-20 19:13 -0700
Message-ID<a4a81083-b218-4859-be97-e91993ea0374@t14g2000yqc.googlegroups.com>
In reply to#8050
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! :)

[toc] | [prev] | [next] | [standalone]


#8058

FromBen Finney <ben+python@benfinney.id.au>
Date2011-06-21 12:41 +1000
Message-ID<8762nzrjnl.fsf@benfinney.id.au>
In reply to#8049
John Salerno <johnjsal@gmail.com> writes:

> 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?

Not as far as I know. Python 2.x classes will not inherit from anything
unless you make them do so explicitly.

-- 
 \      “People demand freedom of speech to make up for the freedom of |
  `\   thought which they avoid.” —Soren Aabye Kierkegaard (1813–1855) |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#8101

FromTerry Reedy <tjreedy@udel.edu>
Date2011-06-21 13:30 -0400
Message-ID<mailman.230.1308677449.1164.python-list@python.org>
In reply to#8049
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web