从 Python 3.x 中的 Python 对象继承是否有必要或有用? [英] Is it necessary or useful to inherit from python's object in Python 3.x?

查看:26
本文介绍了从 Python 3.x 中的 Python 对象继承是否有必要或有用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在较旧的 python 版本中,当您在 python 中创建类时,它可以从 object 继承,据我所知,这是一个特殊的内置 python 元素,它允许您的对象成为新样式对象.

In older python version when you create a class in python, it can inherit from object which is as far I understand a special built-in python element that allow your object to be a new-style object.

新版本(> 3.0 和 2.6)怎么样?我在 google 上搜索了 class 对象,但得到了很多结果(原因很明显).有什么提示吗?

What about newer version (> 3.0 and 2.6)? I googled about the class object but I get so much result (for an obvious reasons). Any hint?

谢谢!

推荐答案

python 3 中不需要从 object 继承新样式.所有类都是新样式.

You don't need to inherit from object to have new style in python 3. All classes are new-style.

这篇关于从 Python 3.x 中的 Python 对象继承是否有必要或有用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆