Python:__cmp__ 和 __str__?

标签 python methods

如果您不为方法 __cmp____str__ 定义自己的方法会怎样?

最佳答案

If no __cmp__(), __eq__() or __ne__() operation is defined, class instances are compared by object identity (“address”).

更多详细信息:请参阅object.__cmp__(self, other) in Python .您可以获得更多引用资料 Special (magic) methods in Python .

关于Python:__cmp__ 和 __str__?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10222077/

相关文章:

java - 什么是脸颊新闻 Activity ?

java - 如何调用 parking 票(parker, parker)?

java - public static int getCoins(int[][] map, int row, int col) 方法

python - 使用 Django 获取 m2m 关系中的 _set.all() 值的更快方法

python - 将带换行符的文本复制到剪贴板 :Python

python - 忽略 re.sub 命令 python 上的 "\n"

python - 如何在代码负载中传递我创建的 slackbot 的用户名/图标?

python - SQLAlchemy - 简单的选择语句

python - C++/嵌入式 Python : Can I retrieve Python file name and line number when a C++ function is called from Python

java - 我该如何让这个 'monster fight simulator' 工作?