Thanks for the replies guys.

I tried the solution below and it works in some cases. But a strange thing
is (remember I'm a newbie) that if I first type, for example a=1 in the
"inputBox" and then hit enter, the debugger goes down to exec
root.inputBox.Text and nothing is reported so I assume the statement is
executed correctly. 

But if I next time type print a in the "inputBox" the debugger goes down to
exec root.inputBox.Text again but now an exception is raised: "name 'a' is
not defined". Why is that??? I typed a=1!

Thanks!


Douglas Blank wrote:
> 
> This is just a Python issue (not specific to IronPython).
> 
> exec is used for statement(s) and eval() for expressions. You might have
> to:
> 
> try:
>    eval(root.inputBox.Text)
> except:
>    exec root.inputBox.Text
> 
> -Doug
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Newbie%3A-convert-string-to-python-expression---tp21029759p21032160.html
Sent from the IronPython mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to