Eric Snow wrote: > On Mon, Aug 8, 2011 at 6:37 AM, Nick <nic...@gmail.com> wrote: >> Is it possible to put a doc string on a class attribute? Something >> like this > > You can put a docstring on a property (which is a function): > > class Test(object): > @property > def fred(self): > "attribute" > return 10
Which, however, doesn't really help: >>> t = Test() >>> t.fred.__doc__ 'int(x[, base]) -> integer\n\nConvert a string or number to an integer ...' The problem is that t.fred returns an integer, so t.fred.__doc__ returns the docstring from the integer, not for the property. >>> t.__class__.fred.__doc__ 'attribute' -- Steven -- http://mail.python.org/mailman/listinfo/python-list