How is the document to access the resource?

I have a property with a docstring, but I cannot access it with help()

.

I tried the following two ways to access it:

class Mini(object):
    @property
    def t(self):
        """ ahhhh """
        return 0

x = Mini()
help(x.t)

class MiniNew(object):
    t = property(doc='This is a doc')

y = MiniNew()
help(y.t)

      

The first one returned Help on int object: blahblahblah

, and the later one returned AttributeError: unreadable attribute

.

What is the correct way to access the property document?

+3


source to share


1 answer


You need to access the property from the class. When accessing an instance, it acts as a return value that is not a document.

class Example(object):
    @property
    def value(self):
        """help text"""
        return 1

help(Example.value)

      



This will print:

Help on property:

    help text

      

+3


source







All Articles