T
TP
Hi everybody,
I know how to document a function or a method, with a docstring (see below
for "foo" method documentation ("bar")).
But, how to document a property (below, self.d)?
#######################
class a():
def __init__( self ):
self.d = 2
def foo( self ):
"bar"
b=a()
print dir(b)
methods = [ el for el in dir( b ) ]
for meth in methods:
if hasattr( getattr( b, meth ), "__doc__" ):
print meth, " :\n", getattr( b, meth ).__doc__
#######################
When I execute this script, I obtain for self.d:
#######################
[...]
__module__ :
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
d :
int(x[, base]) -> integer
Convert a string or number to an integer, if possible. A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!) When converting a string, use
the optional base. It is an error to supply a base when converting a
non-string. If the argument is outside the integer range a long object
will be returned instead.
[...]
#######################
What is this default documentation?
Why?
Thanks
Julien
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z
(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)
I know how to document a function or a method, with a docstring (see below
for "foo" method documentation ("bar")).
But, how to document a property (below, self.d)?
#######################
class a():
def __init__( self ):
self.d = 2
def foo( self ):
"bar"
b=a()
print dir(b)
methods = [ el for el in dir( b ) ]
for meth in methods:
if hasattr( getattr( b, meth ), "__doc__" ):
print meth, " :\n", getattr( b, meth ).__doc__
#######################
When I execute this script, I obtain for self.d:
#######################
[...]
__module__ :
str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
d :
int(x[, base]) -> integer
Convert a string or number to an integer, if possible. A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!) When converting a string, use
the optional base. It is an error to supply a base when converting a
non-string. If the argument is outside the integer range a long object
will be returned instead.
[...]
#######################
What is this default documentation?
Why?
Thanks
Julien
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z
(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)