Class with Object as a parameter

前端 未结 6 1990
攒了一身酷
攒了一身酷 2020-12-22 17:23

I\'m trying to translate some python code to scala code. So I\'m a total noob in Python.

But why do some classes have object as a parameter but never explicitly use

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 17:44

    The Table class is extending a class called object. It's not an argument. The reason you may want to extend object explicitly is it turns the class into a new-style class. If you don't explicitly specify it extends object, until Python 3, it will default to being an old-style class. (Since Python 3, all classes are new-style, whether you explicitly extend object or not.)

    For more information on new-style and old-style classes, please see this question.

提交回复
热议问题