Python:类名中的双冒号

标签 python

我在Python中调试代码时遇到以下情况:

<ROOT.cool::IDatabase object at 0xbc88680>

双冒号的含义是什么,为什么我需要它们?

最佳答案

对我来说,它似乎是 C++ 类函数的 python 包装器,因此 ::

正如 Lattyware 所说,这只是对 python 对象的 __repr__() 调用的返回。

您完全可以确保自己拥有:

class Foo():
    def __repr__(self):
        return "<Foo.bar:::qux::::kludge object at %s>" %hex(id(self))

因此,您无需担心 ::,但您可能需要帮助调试的是对象本身。

关于Python:类名中的双冒号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16133577/

相关文章:

python - 将存储为字符串的 hashID 列表转换为一列唯一值

python - 如何在 Mac OS X 上安装 Python libpcap 模块

Python:保留列表中项目的第一次出现

Python logging.Formatter() : is there any way to fix the width of a field and justify it left/right?

python - Pycharm CE 在我的 Django 项目中没有遇到断点

python - 对字符串进行 URL 编码

这个程序的 Python 内存模型

python - 如何将文本文件读入字符串变量并去除换行符?

c++ - 致命的Python错误: Couldn't create autoTLSkey mapping with C++ binding

python - 为什么我的 QThreads 总是使 Maya 崩溃?