I know we could use exec to load a module ( from a string ) on-the-fly
e.g.
path = 'A.B'
class = 'C'
exec( "from %s import %s" %(path, class) )
but how I could instantiate it as an object c? btw, is above the best way to load a module from a string? it does not look very safe. thanks
regards,
John
For python<=2.6, you can use the built-in
__import__function: