#python
>>> class C(object):
def __init__(self, value):
self._x = value
def _getx(self):
return self._x
def _setx(self, value):
self._x = value
def _delx(self):
del self._x
x = property(_getx, _setx, _delx, doc="I'm the 'x' property.")
>>> obj = C(123)
>>> obj.x
123
>>> obj.x.__doc__
"int(x=0) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to
an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__().
For floating point\nnumbers, this truncates towards zero.\n\nIf x is not a number
or if base is given, then x must be a string,\nbytes, or bytearray instance representing
an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and
be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase
0 means to interpret the base from the string as an integer literal.\n>>> int('0b100',
base=0)\n4"
>>>
Как увидеть "I'm the 'x' property."", а не docstring для int?
Ответы
Ответ 1
Попробуйте: C.x.__doc__ или type(obj).x.__doc__
Комментариев нет:
Отправить комментарий