>>> 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
int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.__int__(). For floating point
numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4"
>>>
Как увидеть "I'm the 'x' property."", а не docstring для int?
Ответ
Попробуйте:
C.x.__doc__
или
type(obj).x.__doc__
Комментариев нет:
Отправить комментарий