Dynamic generation of doc-strings of dynamically generated classes

Alex Martelli aleaxit at yahoo.com
Mon Oct 17 09:55:47 EDT 2005


Mikael Olofsson <mikael at isy.liu.se> wrote:
   ...
> Any ideas? Am I stuck with the clumsy exec-solution, or are there other
> ways to dynamically generate doc-strings of classes?

The best way to make classes on the fly is generally to call the
metaclass with suitable parameters (just like, the best way to make
instances of any type is generally to call that type):

derived = type(base)('derived', (base,), {'__doc__': 'zipp'})


Alex



More information about the Python-list mailing list