dynamic class/module use? (like Java's forName)
Heiko Wundram
heikowu at ceosg.de
Mon Jul 19 13:58:53 EDT 2004
Am Montag, 19. Juli 2004 19:54 schrieb Heiko Wundram:
> ...
> Something like this:
Err, that code was untested, please substitute:
> ====
> Plugins/Module1.py
>
> import Registry
>
> class Callable1(object):
> def __init__(self):
> print "Instantiating Callable1."
>
> def test_method(self,*args,**kwargs):
> print "In test_method."
> print args, kwargs
>
- Registry.register("callable1",Callable1)
+ Registry.registerPlugin("callable1",Callable1)
> ====
> Plugins/Module2.py
>
> import Registry
>
> class Callable2(object):
> def __init__(self):
> print "Instantiating Callable2."
>
- Registry.register("callable2",Callable2)
+ Registry.registerPlugin("callable2",Callable2)
...
HTH!
Heiko.
More information about the Python-list
mailing list