[Tutor] Re: *var*
Magnus Lyckå
magnus@thinkware.se
Wed Jul 9 13:29:02 2003
At 13:29 2003-07-09 -0300, Luiz Siqueira Neto wrote:
>the __doc__ is only a variable defined in some super class to associate
>the documentation or is more of this?
Nope. All names with leading and trailing double underscores are
magic. .__doc__ are constructed as bare strings in the beginning
of a module, class or function/method. They are often triple-quoted
to make it easy to make them several lines.
>Where I can get some about documentation inside a class?
>>> class X:
... """This is class X"""
... def y(self):
... """Method y of class X"""
... print "Hello"
...
>>> X.__doc__
'This is class X'
>>> X.y.__doc__
'Method y of class X'
>>> help(X)
Help on class X in module __main__:
class X
| This is class X
|
| Methods defined here:
|
| y(self)
| Method y of class X
|
| ----------------------------------------------------------------------
| Data and non-method functions defined here:
|
| __doc__ = 'This is class X'
|
| __module__ = '__main__'
>>>
--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language