[IronPython] How do I run python functions and make the python code remember variables between calls from C#?

2009-03-18 Thread BlackMan890
Hi there. When I run the following .py from C#: --- test.py global crap crap = None def set_crap(): crap = yay def return_crap(): return crap --- And run the functions set_crap and return_crap from C# using the following code: ---

Re: [IronPython] How do I run python functions and make the python code remember variables between calls from C#?

2009-03-18 Thread Curt Hagenlocher
Your global statement needs to be inside your set_crap function. On Wed, Mar 18, 2009 at 12:47 AM, BlackMan890 black...@simnet.is wrote: Hi there. When I run the following .py from C#: --- test.py global crap crap = None def set_crap(): crap = yay def

Re: [IronPython] How do I run python functions and make the python code remember variables between calls from C#?

2009-03-18 Thread BlackMan890
Thank you so much :D It is working now :) Curt Hagenlocher wrote: Your global statement needs to be inside your set_crap function. -- View this message in context:

[IronPython] How do I register functions that Python can run from C#?

2009-03-18 Thread BlackMan890
Hi there. I was wondering how one would achieve registering a C# function that python code would be able to call, something like this: --- test.py --- def return_crap(): # do something crap = GetDataFromCSharp() # do some more return crap

Re: [IronPython] How do I register functions that Python can run from C#?

2009-03-18 Thread Michael Foord
Create a delegate and set it in the scope prior to executing. Michael BlackMan890 wrote: Hi there. I was wondering how one would achieve registering a C# function that python code would be able to call, something like this: --- test.py --- def return_crap(): # do

Re: [IronPython] How do I register functions that Python can run from C#?

2009-03-18 Thread Jonatan Nilsson
Hi there Michael Foord. How do I set the delegate inside the scope? Sincerely: Jonatan Nilsson Iceland Michael Foord wrote: Create a delegate and set it in the scope prior to executing. Michael BlackMan890 wrote: Hi there. I was wondering how one would achieve registering a C# function

[IronPython] How come I cant import time or threading in IronPython

2009-03-18 Thread BlackMan890
Hi there. this has probably been answered before but I cant seem to find the answer. When I run import time in python through IronPython using C#, an exception occurs with the message: no module named time. The same thing happens when I run import threading except with a different exception: No

Re: [IronPython] How come I cant import time or threading in IronPython

2009-03-18 Thread Michael Foord
These libraries you are attempting to import are Python standard library modules. To import them you must have the Python standard library available - and on sys.path for the engine being used to do the imports. You set sys.path programattically using engine.SetSearchPaths (?) passing in an

Re: [IronPython] How do I register functions that Python can run from C#?

2009-03-18 Thread Michael Foord
Jonatan Nilsson wrote: Hi there Michael Foord. How do I set the delegate inside the scope? Something like: var something = delegate(string arg) { Console.WriteLine(arg); }; scope.SetVariable(something, something); HTH Michael Foord Sincerely: Jonatan Nilsson Iceland Michael Foord

Re: [IronPython] How do I run python functions and make the python code remember variables between calls from C#?

2009-03-18 Thread Dino Viehland
The documentation for using the hosting APIs is available here: http://dlr.codeplex.com/Wiki/View.aspx?title=Docs%20and%20specsreferringTitle=Home as dlr-hosting-spec.doc -Original Message- From: users-boun...@lists.ironpython.com [mailto:users- boun...@lists.ironpython.com] On

Re: [IronPython] How come I cant import time or threading in IronPython

2009-03-18 Thread Jonatan Nilsson
Thank you for your quick response. I tried doing what you asked me. I added the following to the engine code: --- ScriptEngine engine = Python.CreateEngine(); engine.SetSearchPaths(new string[] { C:\\Program Files\\IronPython-2.0.1\\Lib\\, C:\\Python25\\Lib\\ });

Re: [IronPython] How come I cant import time or threading in IronPython

2009-03-18 Thread Dino Viehland
Do you have IronPython.Modules.dll next to IronPython.dll? IronPython.Modules.dll contains the implementation of thread. -Original Message- From: users-boun...@lists.ironpython.com [mailto:users- boun...@lists.ironpython.com] On Behalf Of Jonatan Nilsson Sent: Wednesday, March 18,

Re: [IronPython] How come I cant import time or threading in IronPython

2009-03-18 Thread Jonatan Nilsson
Ok, I figured it out. I forgot to add C:\\Program Files\\IronPython-2.0.1 and C:\\Python25 Thanks for all the help :D Jonatan Nilsson wrote: Thank you for your quick response. I tried doing what you asked me. I added the following to the engine code: ---

Re: [IronPython] How do I run python functions and make the python code remember variables between calls from C#?

2009-03-18 Thread Tim Roberts
On Wed, 18 Mar 2009 00:47:30 -0700 (PDT), BlackMan890 black...@simnet.is Hi there. When I run the following .py from C#: --- test.py global crap crap = None def set_crap(): crap = yay def return_crap(): return crap --- If you are

[IronPython] Problem importing OS...

2009-03-18 Thread António Piteira
Hello guys, I’m trying to import os lib and I get the following error message: “No module named errno” Any ideas? Thank you ___ Users mailing list Users@lists.ironpython.com

Re: [IronPython] Problem importing OS...

2009-03-18 Thread Michael Foord
Hello Antonio, Can you post the full traceback please? Michael António Piteira wrote: * * * * * * Hello guys, I’m trying to import os lib and I get the following error message: “No module named errno” Any ideas? Thank you * * * * ** * *

Re: [IronPython] Problem importing OS...

2009-03-18 Thread Dino Viehland
Also make sure you have IronPython.Modules.dll next to IronPython.dll (if you're hosting IronPython instead of just running from the command line). -Original Message- From: users-boun...@lists.ironpython.com [mailto:users- boun...@lists.ironpython.com] On Behalf Of Michael Foord

Re: [IronPython] Problem importing OS...

2009-03-18 Thread António Piteira
Hello Michael, Thank you for your reply. I've solved the problem importing nt instead of os. Thank you! --- Hello Antonio, Can you post the full traceback please? Michael António Piteira wrote: * * * * * *