[Tutor] Trying to avoid using eval..

Rohit Mediratta rohit_medi at hotmail.com
Sat Feb 23 03:11:19 CET 2013

Hi All,
   I want to reload my Module after I fix bugs and want to instantiate an object of a class contained in this module.

Heres the pseudo code of what I want to do:

def rerun(testBlock) :
    op = testBlock.split('.')
    module = op[0] ; className = op[1]
    # testBlock is a string, so it needs evaluation!
    newObject = testBlock()


Obviously, line 4 and line 6 dont work today. 
I want to know if there is any smart way to achieve this.
In my previous life (Tcl), I could use 'eval' or 'set' to achieve this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130222/b1cd8ebe/attachment-0001.html>

More information about the Tutor mailing list