My application (C#/WPF) creates Python code for users who are not programmers – they have a selection of drag & drop items and so they create a sequence that the app translates to Python.
That being said, they’d like to add debug capabilities – the option to inject inputs into their sequence during execution (for example, change myVar‘s value from 1 to 2). From what I understand, I should be able to translate that into Python’s input(). I’ve been trying to understand how it works and got the following error(using PythonWin):
>>> a = 1
>>> input('--:)')
--:)>>> a=2
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "<string>", line 1
a=2
^
SyntaxError: invalid syntax
What am I doing wrong?
(Also, some tutorial for debugging capabilities in Python – including input() will be appreciated.)
Edit
We’re working with Python 2.6.6. No need for IronPython – it’s executed in Python environment.
According to python documentation,
input()method is equivalent toeval(raw_input(prompt))andeval()can be used to evaluate expressions only.So for example this code is valid:
but
a=2is a statement so you have to useexec()method to execute it, here is an example: