Is it posible to use docstring for plain variable? For example I have module called t
def f():
\"\"\"f\"\"\"
l = lambda x: x
\"\"\"l\"\"\"
A lot of answers assume you want it for offline use and points to sphinx or Epydoc.
But if you want it for runtime use the answer is that is impossible to add an attribute to another attribute. So you can't attach a doctring to variable.
When you do:
a = True
print(a.__doc__)
You'll be getting the docstring for the bool class. In my application I need it for plug-ins. What I do is to use an associated variable/attribute.
Something like this:
a = True
_help_a = "help for a variable"
As this looks ugly what I'm actually using are syntactic macros (take a look a macropy module). The code looks like this:
with document:
a = True
""" help for a variable """
I explain the whole idea here