[BangPypers] Python code documentation doubt
steve
steve at lonetwin.net
Thu Apr 22 09:27:50 CEST 2010
On 04/22/2010 12:29 PM, JAGANADH G wrote:
> Dear All
>
> where can I find some guide/guidelines for code documentation like this
>
>
> >>> single_record.pmid
> u'7024555'
> single_record +
> - B{.title}
> - B{.pmid}
> - B{.Abs} I{(abstracts)}
> - B{.year}
>
> I am looking for a guide to learn the technique of writing such kind of code
> document in my module.
>
From what you've posted, it looks more like the __repr__ of the 'pmid' object
rather than code documentation. Here is a console session (pretty self
explanatory) demonstrating the use of __repr__ ...and a bit more (ie: the
difference between that and __str__ ) :
------------------------------------------
>>> class A:
... def __init__(self, x):
... self.x = x
...
... def __str__(self):
... return str(self.x)
...
... def __repr__(self):
... return "I am a %s with the value %d" % (self.__class__, self.x)
...
>>> a = A()
>>> a = A(10)
>>> a
I am a __main__.A with the value 10
>>> print a
10
>>>
------------------------------------------
If you need additional explanation or clarification, please ask.
hth,
cheers,
- steve
--
random new spiel: http://lonetwin.net/
random old spiel: http://lonetwin.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
More information about the BangPypers
mailing list