Why inherit object in classes?

This is the place for queries that don't fit in any of the other categories.

Why inherit object in classes?

Postby dboxall123 » Fri Sep 27, 2013 6:00 pm

Hi all. What is the difference between inheriting object in classes and not inheriting anything? For example, what is the difference between
Code: Select all
class Animal(object):
    def __init__(self):
        self.type = None
        self.name = None
        self.weight = None
and
Code: Select all
class Animal():
    def __init__(self):
        self.type = None
        self.name = None
        self.weight = None
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm

Re: Why inherit object in classes?

Postby micseydel » Fri Sep 27, 2013 6:25 pm

In Python 3 it's done implicitly. It just gives you new style classes, which work nicer with super(). I'm pretty sure in my ~8 years of Python, it's never really come up except when I was reading about it in a tutorial. Don't worry about it too much unless you're doing fancy OOPy things.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 1128
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Why inherit object in classes?

Postby dboxall123 » Fri Sep 27, 2013 7:58 pm

Ok, sweet, cheers mate! :D
dboxall123
 
Posts: 108
Joined: Fri Jul 12, 2013 5:28 pm


Return to General Coding Help

Who is online

Users browsing this forum: Larz60+, snippsat and 4 guests