What is the difference between the two? Don't both of these have the same functionality? I don't understand the whole point of the object
parameter.
class Car(object): # object parameter
def foobar():
print("Hello World!\n")
vs.
class Car(): # No parameter
def foobar():
print("Hello World!\n")
In Python 2, the former is a "new-style class" and the latter is an "old-style class" that only exists for backwards compatibility. You should never use the latter for anything new.
In Python 3, I believe there is no difference at all. You can even leave out the parentheses entirely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With