class definition question
Manfred Lotz
ml_news at posteo.de
Wed Aug 7 15:26:13 EDT 2019
On Wed, 07 Aug 2019 14:39:00 -0400
Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
> On Wed, 7 Aug 2019 20:11:15 +0200, Manfred Lotz <ml_news at posteo.de>
> declaimed the following:
>
> >Hi there,
> >More often I see something like this:
> >
> >class Myclass:
> >...
> >
> >
> >but sometimes I see
> >
> >class Myclass(object):
> >...
> >
> >
> >Question: which way is preferable?
>
> It's historical...
>
> Python v1.x had a form of classes.
>
> Python v2.x introduced "new-style" classes. "New-style"
> classes /had/ to inherit from "object", as they had different
> behavior from "v1.x old-style" classes which were still supported (it
> would have broken too many programs). Old-style were then deprecated,
> and one should have used new-style for new code.
>
> Python v3.x unified (removed old-style behavior differences)
> and all classes inherit from "object" whether one specifies object or
> not.
>
>
Thanks a lot for the explanations.
As a Python newbie (with no Pythons legacies) I only deal with Python 3.
So, I will happily ignore 'object'.
--
Manfred
More information about the Python-list
mailing list