How to load new class definitions at runtime?

SM sjmaster at gmail.com
Mon Nov 15 18:55:35 EST 2004


aleaxit at yahoo.com (Alex Martelli) wrote in message news:<1gn8ja3.7d3sbhuk94khN%aleaxit at yahoo.com>...
> If you need [classes] to be _updatable_ at runtime, look at a recipe by
> Michael Hudson in the cookbook -- I've updated it for the printed
> version 2nd ed (since we do have __subclasses__ now, yay!) but that's
> not done yet.  My vote for most useful custom metaclasses ever...

That recipe is here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164

Is it correct that this metaclass solution does not handle changes to
__init__, including new attributes that are bound there? I.e., it
basically only deals with modification or addition or deletion of
methods; if you need to add new attributes or have any other new code
in __init__, you'll have to make new instances for all the old
instances, or deal with it some other way. In which case would you be
better off just using that other way from the start?



More information about the Python-list mailing list