I'm working on providing an extensibility mechanism for my C# mapmaking application through IronPython. Everything works fine, but I have a specific requirement which I'm having trouble implementing: I want the user to be able to specify two things:
- A file name of the Python script to be loaded
- A one-liner string containing Python script which would typically be a call of a function from that Python file (example
getTextLabel(element))
These two settings must be separate, but I don't know if it is possible to do this using PythonScript and related classes.
I'm a newbie in Python, perhaps there is another way to achieve this? For performance reasons I want to avoid loading and compiling the Python script file several times (since there could be several above mentioned different "function call" settings and I want to reuse the CompiledCode instance for the file if possible).
UPDATE: @digEmAll gave the correct answer to my question, so I'm accepting it as a valid answer. But if you are concerned with performance, you should also check out my own answer.