Re: Docstrings and class Attributes

2011-08-10 Thread Ben Finney
Steven D'Aprano writes: > So just because a feature is an accident of history, doesn't mean that > a use can't be found for it. Which I explicitly noted in my message. I suppose it's inevitable for the nuances of one's utterances to be forgotten as the discussion progresses, but darn if it ain't

Re: Docstrings and class Attributes

2011-08-10 Thread Steven D'Aprano
John Pinner wrote: > On Aug 9, 1:36 am, Ben Finney wrote: >> Ethan Furman writes: >> > So if property docstrings are so hard to get to, what's the point in >> > having them? >> >> Why would you expect there be a special point to them? >> >> Men, like all primates of any sex, have nipples. >> >>

Re: Docstrings and class Attributes

2011-08-10 Thread John Pinner
On Aug 9, 1:36 am, Ben Finney wrote: > Ethan Furman writes: > > So if property docstrings are so hard to get to, what's the point in > > having them? > > Why would you expect there be a special point to them? > > Men, like all primates of any sex, have nipples. > > Properties, like any function i

Re: Docstrings and class Attributes

2011-08-08 Thread Ben Finney
Steven D'Aprano writes: > Ben Finney wrote: > > > They're an accident of the history that led to their implementation, > > and of the pre-existing parts that they're built from. There doesn't > > need to be a point to them (though they might be useful for reasons > > incidental for the reasons th

Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Ben Finney wrote: > Ethan Furman writes: > >> So if property docstrings are so hard to get to, what's the point in >> having them? > > Why would you expect there be a special point to them? > > Men, like all primates of any sex, have nipples. > > Properties, like any function in Python, have

Re: Docstrings and class Attributes

2011-08-08 Thread Ben Finney
Ethan Furman writes: > So if property docstrings are so hard to get to, what's the point in > having them? Why would you expect there be a special point to them? Men, like all primates of any sex, have nipples. Properties, like any function in Python, have docstrings. They're an accident of t

Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 1:05 PM, Steven D'Aprano wrote: > Ethan Furman wrote: > >> So if property docstrings are so hard to get to, what's the point in >> having them? > > Hard to get, not impossible. But I have no idea really -- they don't seem > very useful to me. They do show up in help(), but

Re: Docstrings and class Attributes

2011-08-08 Thread Chris Kaynor
They are actually quite easy to get to. help() on both the class or instance produces the docstring, and __doc__ on the property as accessed from the class produces the docstring. >>> class Test(object): ... @property ... def fred(self): ... """*This is a docstring.*""" ...

Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Ethan Furman wrote: > So if property docstrings are so hard to get to, what's the point in > having them? Hard to get, not impossible. But I have no idea really -- they don't seem very useful to me. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Docstrings and class Attributes

2011-08-08 Thread Terry Reedy
On 8/8/2011 2:26 PM, Steven D'Aprano wrote: Eric Snow wrote: On Mon, Aug 8, 2011 at 6:37 AM, Nick wrote: Is it possible to put a doc string on a class attribute? This really makes little sense. The purpose of docstrings is to give interactive help. The place to document data attributes of

Re: Docstrings and class Attributes

2011-08-08 Thread Ethan Furman
Steven D'Aprano wrote: Eric Snow wrote: On Mon, Aug 8, 2011 at 6:37 AM, Nick 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): "attrib

Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Nick wrote: > Is it possible to put a doc string on a class attribute? Something > like this > > class Test (object): > '''classx''' > fred = 10 > '''attribute''' The short answer is, no. The longer answer is, maybe, if you can make Test.fred be some sort of object with a docstring

Re: Docstrings and class Attributes

2011-08-08 Thread Steven D'Aprano
Eric Snow wrote: > On Mon, Aug 8, 2011 at 6:37 AM, Nick 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"

Re: Docstrings and class Attributes

2011-08-08 Thread Terry Reedy
On 8/8/2011 8:37 AM, Nick wrote: Is it possible to put a doc string on a class attribute? Class and function docstrings are generated from string expression statements at the beginning of a suite. class Test (object): '''classx''' fred = 10 '''attribute''' This is two stat

Re: Docstrings and class Attributes

2011-08-08 Thread Eric Snow
On Mon, Aug 8, 2011 at 6:37 AM, Nick 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 Python syntax sup

Docstrings and class Attributes

2011-08-08 Thread Nick
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 inte