This is very much worth doing: generate an assembly by precompiling a Python source file and then look at the result using Reflector.
On Wed, Jan 21, 2009 at 8:28 AM, Dody Gunawinata <[email protected]>wrote: > hmm..why would an IronPython assembly be different from a static language > assembly? Wouldn't that negates the main point of the CLR? > > Dody G. > > On Wed, Jan 21, 2009 at 6:20 PM, Michael Foord > <[email protected]>wrote: > >> Dody Gunawinata wrote: >> >>> string cmd = @"from xxx import yy"; >>> >>> eng.CreateScriptSourceFromString(cmd).Execute(--fill in default scope >>> here--) >>> >> It will need to be: >> >> eng.CreateScriptSourceFromString(cmd, >> SourceCodeKind.Statements).Execute(scope) >> >> But I'm pretty sure he will also need to use a different API for loading >> the assembly, assuming it is from compiled IronPython code rather than just >> an ordinary .NET assembly. >> >> Michael >> >> >>> //then go one fetching the function >>> >>> On Wed, Jan 21, 2009 at 6:11 PM, Renaud Durand <[email protected]<mailto: >>> [email protected]>> wrote: >>> >>> That is the point. I don't want to do that from a file but from an >>> Assembly (dll). >>> >>> 2009/1/21 Dino Viehland <[email protected] >>> <mailto:[email protected]>> >>> >>> You need to do: >>> >>> >>> eng.ExecuteFile('myfile.py', scope); >>> >>> >>> *From:* [email protected] >>> <mailto:[email protected]> >>> [mailto:[email protected] >>> <mailto:[email protected]>] *On Behalf Of >>> *Renaud Durand >>> *Sent:* Wednesday, January 21, 2009 7:45 AM >>> *To:* [email protected] <mailto:[email protected]>; >>> Discussion of IronPython >>> *Subject:* Re: [IronPython] Calling a Python function >>> (compiled into an assembly) from C# using delegates. >>> >>> >>> Ok, but how ? >>> >>> 2009/1/21 Dody Gunawinata <[email protected] >>> <mailto:[email protected]>> >>> >>> I think you have to import the function - loading the assembly >>> alone is not enough. >>> >>> On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand >>> <renaud.durand.it <http://renaud.durand.it>@gmail.com >>> >>> <http://gmail.com>> wrote: >>> >>> Hi again, >>> >>> I'm trying to call a python function from C#. I found out >>> through a tutorial how to do it from >>> a Python source file but I would like to do it from a >>> compiled assembly. Some elements are missing. >>> I think it is something like below but this does not work: >>> >>> eng = Python.CreateEngine() >>> Assembly interpreter = >>> Assembly.Load("interpreter"); >>> eng.runtime.LoadAssembly(interpreter); >>> ScriptScope scope = >>> eng.CreateScope(); >>> >>> //Get the interpretMapping function >>> Func<string, object> interpretMapping; >>> interpretMapping = >>> scope.GetVariable<Func<string, object>>("interpretMapping"); >>> ObjectOperations ops = eng.Operations; >>> >>> //Get the interpItem returned by function. >>> object item = >>> >>> >>> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); >>> //Get the display Method >>> object method = ops.GetMember(item, "display"); >>> ops.Call(method); >>> >>> Thank you... Again :-) >>> >>> -- Renaud Durand >>> EPITA Student >>> >>> _______________________________________________ >>> Users mailing list >>> [email protected] <mailto:[email protected] >>> > >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- nomadlife.org <http://nomadlife.org> >>> >>> >>> _______________________________________________ >>> Users mailing list >>> [email protected] <mailto:[email protected]> >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- Renaud Durand >>> >>> >>> _______________________________________________ >>> Users mailing list >>> [email protected] <mailto:[email protected]> >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- Renaud Durand >>> >>> _______________________________________________ >>> Users mailing list >>> [email protected] <mailto:[email protected]> >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- >>> nomadlife.org <http://nomadlife.org> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Users mailing list >>> [email protected] >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >> >> > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
