properties give variable docstrings
tjhnson at gmail.com
tjhnson at gmail.com
Wed Dec 12 23:52:45 EST 2007
The topic of docstrings for variables has come up many times before.
In fact, a PEP was proposed and rejected on this very topic.
http://www.python.org/dev/peps/pep-0224/
When creating classes, I like using properties...and I like even more
that these properties have docstrings. This allows one to
interactively explore the API and understand (in a limited sense) what
the variables mean in the context of the class. I am in a situation
where I need to add a large number of properties to a class (the
properties are almost identical...differing only by a docstring)...
The topic of dynamically generating properties has been discussed
here:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/3d682513cd7551d8?hl=en
The conclusion there seems to suggest that I'd probably be better off
using __getattr__. This makes sense, but the downside is that I no
longer have docstrings for my attributes.
So, I'm wondering what others think...is it worthwhile to define
properties just so that I can have docstrings for attributes? Or is
creating a bunch of properties overkill in every possible way....
More information about the Python-list
mailing list