Docstrings and class Attributes
Nick
nickle at gmail.com
Mon Aug 8 08:37:34 EDT 2011
Is it possible to put a doc string on a class attribute? Something
like this
class Test (object):
'''classx'''
fred = 10
'''attribute'''
print Test.__doc__
print Test.fred.__doc__
This code produces this output
classx
int(x[, base]) -> integer
Convert a string or number to an integer, if possible. A floating
point
argument will be truncated towards zero (this does not include a
string
representation of a floating point number!) When converting a string,
use
the optional base. It is an error to supply a base when converting a
non-string. If base is zero, the proper base is guessed based on the
string content. If the argument is outside the integer range a
long object will be returned instead.
===========
So the class doc string is return, but no doc string for the
attribute.
More information about the Python-list
mailing list