Michael,<br><br>Thank you for your help! It finally works. Now there is lots of other things left but this has really helped a lot.<br><br><br><br><div class="gmail_quote">2008/12/16 Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">Kristian Jaksch wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Michael,<br>
<br>
What do you mean exec the import * inside the context to poulate it? Something like:<br>
<br>
*context['Mapack'] = exec "from Mapack import *" #Doesn't work<br>
<br>
*Hmmm... think I'm getting tired.<br>
<br>
</blockquote></div>
exec doesn't return anything.<br>
<br>
Try:<br>
<br>
*exec "from Mapack import *" in context*<br>
<br>
It looked like from your response to Orestis that you were moving away from using an explicit context - which I think will get you into confusion with local variables created by your user code.<br>
<br>
Michael<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Anyway thanks for help!<br>
<br>
<br>
<br>
2008/12/16 Michael Foord <<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a> <mailto:<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>>><div>
<div></div><div class="Wj3C7c"><br>
<br>
Michael Foord wrote:<br>
<br>
Kristian Jaksch wrote:<br>
<br>
*<br>
def inputBox_KeyDown(s, e):<br>
key = e.Key.value__<br>
result = root.inputBox.Text<br>
if key == 3: #If 'Enter' key is pressed<br>
try:<br>
try:<br>
root.message.Text = eval(result)<br>
except SyntaxError:<br>
exec result in context<br>
except Exception, e:<br>
print 'Unhandled exception', e<br>
root.inputBox.Text = "" #Clearing inputBox*<br>
<br>
But this creates a fixed size matrix and I still get an<br>
exception if I type for example *m=Matrix(2,2)* in the<br>
'inputBox'. I want to make this as general as possible.<br>
Can't I place everything that is imported from 'Mapack'<br>
into the 'context' dictionary together with whatever the<br>
user types in besides of that?<br>
<br>
<br>
You can. I'll give you a clue - import * makes it harder. Try<br>
importing Mapack and then it will be easier to put things from<br>
the module into the dictionary.<br>
<br>
<br>
Hmmm - actually you could exec the import * inside the context to<br>
populate it.<br>
<br></div></div><div class="Ih2E3d">
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br>
</div></blockquote><div><div></div><div class="Wj3C7c">
<br>
<br>
-- <br>
<a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
<a href="http://www.voidspace.org.uk/blog" target="_blank">http://www.voidspace.org.uk/blog</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</div></div></blockquote></div><br>