[pyar] duda existencial ... Puedo permitirme comentar codigo con ''' ?!
Esteban Kuber
ekuber en gmail.com
Vie Ago 27 22:29:42 ART 2010
>> Creo que en algún momento hubo una propuesta para hacer docstrings
>> para variables, que probablemente haya sido rechazado, pero podrías
>> usarlo para algo así.
>
> Pero funciona!
>
> Bah, por lo menos para las variables dentro de una clase, a veces.
>
> class f():
> """
> Una clase
> """
>
> x = 2
> "Una variable"
>
> No funciona con help pero funciona con epydoc :-)
>From epydoc's manual[0]:
Variable docstrings
Python don't support directly docstrings on variables: there is no
attribute that can be attached to variables and retrieved
interactively like the __doc__ attribute on modules, classes and
functions.
While the language doesn't directly provides for them, Epydoc supports
variable docstrings: if a variable assignment statement is immediately
followed by a bare string literal, then that assignment is treated as
a docstring for that variable. In classes, variable assignments at the
class definition level are considered class variables; and assignments
to instance variables in the constructor (__init__) are considered
instance variables:
class A:
x = 22
"""Docstring for class variable A.x"""
def __init__(self, a):
self.y = a
"""Docstring for instance variable A.y
Variables may also be documented using comment docstrings. If a
variable assignment is immediately preceeded by a comment whose lines
begin with the special marker '#:', or is followed on the same line by
such a comment, then it is treated as a docstring for that variable:
#: docstring for x
x = 22
x = 22 #: docstring for x
Notice that variable docstrings are only available for documentation
when the source code is available for parsing: it is not possible to
retrieve variable
---
La PEP correspondiente[1]. Del 2000, rejected.[2]
[0]: http://epydoc.sourceforge.net/manual-docstring.html
[1]: http://www.python.org/dev/peps/pep-0224/
[2]: Yes, I use 0 based arrays, as the Flying Spagetti Monster
intended, be his noodly appendage be praised.
More information about the pyar
mailing list