[IronPython] Hosting: passing arguments to scripts?

Dino Viehland dinov at exchange.microsoft.com
Wed Jun 18 08:24:51 PDT 2008


That's probably the best way to do it right now - we need to provide a service for Python specific information (exposed via ScriptEngine.GetService) or provide a PythonEngine wrapper which enables Python specific behavior.  At this point that might be a feature that waits for post 2.0 though.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Christian Muirhead
Sent: Wednesday, June 18, 2008 8:07 AM
To: Discussion of IronPython
Subject: [IronPython] Hosting: passing arguments to scripts?

Hey guys -

I'm looking at running Resolver One on IP2B3, and it took a long time to
  work out how to pass an argument in to a script to run - it seemed
like I should be able to set the ScriptEngine.Options.Arguments, but
that resulted in an empty sys.argv. In the end I dug around in the
source and found the following, which works:

     List argList = new List();
     argList.extend(args);
     PythonContext context =
(PythonContext)HostingHelpers.GetLanguageContext(engine);
     context.SystemState.Dict[SymbolTable.StringToId("argv")] = argList;

There are comments on HostingHelper not really being intended for hosts
- is there a better/less likely to go away method of doing this?

Thanks,
Christian

--
Christian Muirhead
Resolver Systems
christian.muirhead at resolversystems.com
We're hiring! http://www.resolversystems.com/jobs/


Resolver Systems Ltd
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company
number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Users mailing list