What is the difference between the two classes below? Do you have some related information about this case? Thank you very much.
class test(object):
def __init__(self, name):
print name
class test():
def __init__(self, name):
print name
In python 2.x, the class that inherits from object
will be a new-style class, while the other won't, while in python 3.x there'll be both new-style.
However, the differences between new and old are rather advanced, (for example, attribute search order) so a beginner shouldn't be too concerned about the incompatibilities.
See this answer for more information if you're interested, but it's rather a thing for library developers etc.
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