KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Thanks to suggestions from a previous question , I'm busy trying out IronPython, IronRuby and Boo to create a DSL for my C# app. Step one is IronPython, due to the larger user and knowledge base. If I can get something to work well here, I can just stop. Here is my problem: I want my IronPython script to have access to the functions in a class called Lib. Right now I can add the assembly to the IronPython runtime and import the class by executing the statement in the scope I created: // load 'ScriptLib' assembly Assembly libraryAssembly = Assembly.LoadFile(libraryPath); _runtime.LoadAssembly(libraryAssembly); // import 'Lib' class from 'ScriptLib' ScriptSource imports = _engine.CreateScriptSourceFromString("from ScriptLib import Lib", SourceCodeKind.Statements); imports.Execute(_scope); // run .py script: ScriptSource script = _engine.CreateScriptSourceFromFile(scriptPath); script.Execute(_scope); If I want to run Lib::PrintHello, which is just a hello world style statement, my Python script contains: Lib.PrintHello() or (if it's not static): library = new Lib() library.PrintHello() How can I change my environment so that I can just have basic statments in the Python script like this: PrintHello TurnOnPower VerifyFrequency TurnOffPower etc... I want these scripts to be simple for a non-programmer to write. I don't want them to have to know what a class is or how it works. IronPython is really just there so that some basic operations like for, do, if, and a basic function definition don't require my writing a compiler for my DSL.
Tags (comma-separated)
Save Edits
Cancel