Python 为什么属性文档函数没有';当通过帮助(instance.attribute)调用帮助信息时,不显示帮助信息

Python 为什么属性文档函数没有';当通过帮助(instance.attribute)调用帮助信息时,不显示帮助信息,python,Python,问题>如果通过帮助(mything的实例)调用,我的东西的帮助消息,为什么不显示 Reference当您访问.my\u thing的实例时,它返回值-因此您实际调用的帮助是值1,而不是属性 如果您在类对象而不是实例上访问它,您将获得property对象,并且docstring将附加到它;也就是说,使用help(MyClass.my\u thing)或help(type(instance\u of.my\u thing) class MyClass(object): def __init_

问题>如果通过
帮助(mything的实例)
调用,
我的东西
的帮助消息,为什么不显示


Reference

当您访问.my\u thing的
实例时,它返回值-因此您实际调用的
帮助
是值
1
,而不是属性

如果您在类对象而不是实例上访问它,您将获得property对象,并且docstring将附加到它;也就是说,使用
help(MyClass.my\u thing)
help(type(instance\u of.my\u thing)

class MyClass(object):
    def __init__(self):
        self._my_secret_thing = 1

    def _i_get(self):
        return self._my_secret_thing

    def _i_set(self, value):
        self._my_secret_thing = value

    def _i_delete(self):
        del self._my_secret_thing

    my_thing = property(_i_get, _i_set, _i_delete,'this document for my_thing')

instance_of = MyClass()

help(instance_of.my_thing) # not display the 'this document for my_thing'
help(instance_of)          # display the 'this document for my_thing'