![]() |
When to derive from object?
Hello all!
I'm a newbie to Python. Could you please say me when it is better to derive from "object" and when not? Thanks, Igor |
Re: When to derive from object?
Igor Mikushkin a écrit :
> Hello all! > > I'm a newbie to Python. Welcome onboard > Could you please say me when it is better to derive from "object" and > when not? - When not : when using Python >= 3.0, or when already subclassing another class. - When : any other case !-) |
Re: When to derive from object?
On Oct 13, 7:45*am, Igor Mikushkin <igor.mikush...@gmail.com> wrote:
> Hello all! > > I'm a newbie to Python. > Could you please say me when it is better to derive from "object" and > when not? > > Thanks, > Igor The only reason to derive from 'object' is if there is some sort of weird side effect of using new style classes. I _have_ run into some interesting scenarios when creating com objects in python using the win32com module. Other than that, I always use new style classes (derived from object). Here are some articles that point out the distinctions between old and new style classes: http://python.org/doc/newstyle/ Matt |
Re: When to derive from object?
On Oct 13, 8:02*am, Matimus <mccre...@gmail.com> wrote:
> On Oct 13, 7:45*am, Igor Mikushkin <igor.mikush...@gmail.com> wrote: > > > Hello all! > > > I'm a newbie to Python. > > Could you please say me when it is better to derive from "object" and > > when not? > > > Thanks, > > Igor > > The only reason to derive from 'object' is ... erm... that should say "the only reason _not_ to derive from object" oops. Matt |
Re: When to derive from object?
Can someone point me to some reason on why not to derive from Object
when using Python >= 3.0? I am a Python novice, I need some background. On Oct 13, 10:49*am, Bruno Desthuilliers <bruno. 42.desthuilli...@websiteburo.invalid> wrote: > Igor Mikushkin a écrit : > > > Hello all! > > > I'm a newbie to Python. > > Welcome onboard > > > Could you please say me when it is better to derive from "object" and > > when not? > > - When not : when using Python >= 3.0, or when already subclassing > another class. > > - When : any other case !-) |
Re: When to derive from object?
On Tue, Oct 13, 2009 at 1:34 PM, Anson Mackeracher <amackera@gmail.com> wrote:
> Can someone point me to some reason on why not to derive from Object > when using Python >= 3.0? I am a Python novice, I need some > background. > It's redundant. Python 3 cleaned up a lot of the warts that appeared in Python over the years. Old-style classes (classes that didn't inherit from object) were one of them. Every class in Python 3 is derived from object whether you specify it or not. > On Oct 13, 10:49*am, Bruno Desthuilliers <bruno. > 42.desthuilli...@websiteburo.invalid> wrote: >> Igor Mikushkin a écrit : >> >> > Hello all! >> >> > I'm a newbie to Python. >> >> Welcome onboard >> >> > Could you please say me when it is better to derive from "object" and >> > when not? >> >> - When not : when using Python >= 3.0, or when already subclassing >> another class. >> >> - When : any other case !-) > > -- > http://mail.python.org/mailman/listinfo/python-list > |
Re: When to derive from object?
Benjamin Kaplan <benjamin.kaplan@case.edu> writes:
> > It's redundant. Python 3 cleaned up a lot of the warts that appeared > in Python over the years. Old-style classes (classes that didn't > inherit from object) were one of them. Every class in Python 3 is > derived from object whether you specify it or not. .... it could be argued that having two ways to specify the same thing (derivation from object explictly or implicitly) is a wart in itself :/ |
Re: When to derive from object?
Paul Rudin wrote:
> Benjamin Kaplan <benjamin.kaplan@case.edu> writes: > >> It's redundant. Python 3 cleaned up a lot of the warts that appeared >> in Python over the years. Old-style classes (classes that didn't >> inherit from object) were one of them. Every class in Python 3 is >> derived from object whether you specify it or not. > > ... it could be argued that having two ways to specify the same thing > (derivation from object explictly or implicitly) is a wart in itself :/ Every function with default arguments can be called two or more ways. Every function that returns None can be written two or more ways. ;-) |
Re: When to derive from object?
Terry Reedy wrote:
> Every function with default arguments can be called two or more ways. > Every function that returns None can be written two or more ways. And in general, anything of any sort with any kind of default can be written in two ways. Somehow I doubt that the ZoP was intended to discourage providing defaults! -- Greg |
| All times are GMT. The time now is 07:35 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.