[IronPython] Evaluating python from within the context of a class

Michael Stephens falcon at uwyo.edu
Fri Jun 27 18:43:39 CEST 2008


I want to be able to execute arbitrary expressions but have their context be
within my class.  The end result is that RT test should be printed and not
global test

def test():
 print "global test"

class RT:
 def test(_self_):
  print 'RT test'
 def Evaluate(_self_,code):
  eval(code)


test()
a.test()
a=RT()
a.Evaluate('test()')

Michael Stephens

Electrical Engineering Graduate Student
University of Wyoming
falcon at uwyo.edu or 89iroc at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080627/81818d8c/attachment.html>


More information about the Ironpython-users mailing list