Docstrings and class Attributes

Nick nickle at
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):

    fred = 10

print Test.__doc__
print Test.fred.__doc__

This code produces this output

int(x[, base]) -> integer

Convert a string or number to an integer, if possible.  A floating
argument will be truncated towards zero (this does not include a
representation of a floating point number!)  When converting a string,
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

More information about the Python-list mailing list