hi, what is the difference between : class Shape(object) and class Shape()? hi, what is the difference between : class Shape(object) and class Shape()? @MIT 6.00 Intro Co…
Might be wrong, and if I am, maybe someone can correct me, but, the difference is very subtle, in that it amounts to "new-style" class vs. "old-style" class. TLDR version: class Shape(object) - inheriting from object base class - is the new style(implemented in Python 3.x), whilst class Shape() is "old-style" class, but there are really minor differences between them. One could say, they can surely be overlooked. http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python Check this link for more info about the new-style x old-style discussion.
I mean, they can be overlooked except for compatibility of your code.
new-style classes offer desirable features, like descriptors, properties, static methods - more reading :) http://docs.python.org/reference/datamodel.html#new-style-and-classic-classes http://www.python.org/doc/newstyle/ http://docs.python.org/howto/descriptor.html#descriptor-howto-guide http://en.wikibooks.org/wiki/Python_Programming/Classes http://www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html http://www.cafepy.com/article/python_types_and_objects/python_types_and_objects.html
Join our real-time social learning platform and learn together with your friends!