Code to add docstrings to classes
matt at tplus1.com
Tue Sep 12 16:53:28 CEST 2006
On Tue 12 Sep 2006 10:06:27 AM EDT, Neil Cerutti wrote:
> Writing a thin wrapper around the dictionary might be beneficial,
> and would also furnish a place for the docstrings.
I wrote a function that hopefully does just that. I'm not very savvy at
doing this class-factory stuff, so any advice would be welcome.
Return a subclass of class C that has a instance-level attribute _vardoc.
def __init__(self, *args, **kwargs):
vardoc = kwargs.get('vardoc')
assert isinstance(vardoc, str), "vardoc must be a
self._vardoc = vardoc
C.__init__(self, *args, **kwargs)
return self._vardoc + "\n" + C.__repr__(self)
i = vd(int)(6)
i._vardoc = "integer!"
assert isinstance(i, int)
d = vd(dict)(a=1, b=2, c=i, vardoc="dict!")
assert d['a'] == 1
assert d['c'] == 6
assert isinstance(d, dict)
A better way of running series of SAS programs:
More information about the Python-list