[IronPython] Executing a python source from C#

Ryan Davis ryan at acceleration.net
Fri Apr 29 13:48:36 PDT 2005


What I'd really like is the ability to create a .dll that we reference in other .NET apps, just as now we can write a class library
in C# and use it in a VB.NET web application.
 
I have zero clue of the complexity of that task, but that'd be my ideal.  I imagine that'd be pretty hard, given the differences in
function declaration semantics alone.  I'm thinking of **kwargs and default parameters, specifically.  I don't know how that would
map to a C# compatible signature.  I guess for default parameters:
 
def foo(a=1, b=2, c=4):
 
you could make successive overloads that call one "master" version:
 
int foo(a)
int foo(a,b)
int foo(a,b,c)
 
but then there's no way to do the equivalent of foo(b=3) without running into ambiguity, and you end up having to do a lot more
function calls than you really should.  
 
.. back to C# sloggery.
Thanks,
Ryan 
  _____  

From: users-ironpython.com-bounces at lists.ironpython.com [mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of
Keith J. Farmer
Sent: Friday, April 29, 2005 2:27 PM
To: Discussion of IronPython
Subject: RE: [IronPython] Executing a python source from C#
 
I think having a standard interface for creating consoles would be a great way to implement IronPython's console.  Being able to
swap in semi-arbitrary languages into FooConsole could be useful for a variety of apps.
 
public delegate ConsoleInputHandler(string input);
 
IConsole console = new Console<IronPythonInterpreter>(consoleSettings, consoleHistory);
console.OnInput += new ConsoleInputHandler(OnInput);
 
public void OnInput(string input)
{
console.SubmitLine(input);
 
switch(console.State)
{
case ConsoleState.ContinueLine: { console.Prompt = ConsolePrompt.Continue; break; }
case ConsoleState.NewLine: { console.ExecuteCurrentLine();  prompt = ConsolePrompt.New; break; }
}
}
 
.. back to Java sloggery.
 
  _____  

From: users-ironpython.com-bounces at lists.ironpython.com on behalf of Jim Hugunin
Sent: Fri 4/29/2005 10:46 AM
To: Discussion of IronPython
Subject: RE: [IronPython] Executing a python source from C#
That will generate a SyntaxError just as if you passed a partial block to exec.  If you're interested in experimenting with
embeddable consoles, you should take a look at the code for IronPythonConsole which also uses PythonEngine to do its loops.

Ultimately, I think that IronPython should ship with a standard interactive console for both winforms and avalon that have a few
customization hooks but are designed to be easily plugged into your apps.  I'm still not sure if this embeddable console should be
written in C# or in IronPython itself and am curious to hear the results of experiments using either approach.  I'm leaning towards
the idea of building it, and even the standard command-line console, in IronPython.

Thanks - Jim

________________________________________
From: users-ironpython.com-bounces at lists.ironpython.com [mailto:users-ironpython.com-bounces at lists.ironpython.com] On Behalf Of
Keith J. Farmer
Sent: Friday, April 29, 2005 10:35 AM
To: Discussion of IronPython
Subject: RE: [IronPython] Executing a python source from C#

What happens if we send in a partial block, as might happen when creating an embeddable console?
string stmt = "for i in range(6):";
engine.Execute(stmt);
Or is it expected that we ensure that such things don't happen?
 
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 11046 bytes
Desc: not available
Url : http://listserver.dreamhost.com/pipermail/users-ironpython.com/attachments/20050429/e787c5de/winmail.bin


More information about the users-ironpython.com mailing list