[IronPython] no module named re

Slide slide.o.mix at gmail.com
Tue Mar 15 17:38:13 CET 2011


Yes, but I just found that it was not being copied to the bin
directory during build for some reason.

Sorry for the noise.

slide

On Tue, Mar 15, 2011 at 9:29 AM, Jimmy Schementi <jimmy at schementi.com> wrote:
> Is IronPython.Modules.dll referenced by the host app?
> ~Jimmy
>
>
> On Tue, Mar 15, 2011 at 12:22 PM, Slide <slide.o.mix at gmail.com> wrote:
>>
>> I am embedding IronPython in my app to allow some script capabilities.
>> I have the following code:
>>
>> _content = content.Trim();
>>
>>            string script = string.Format(@"
>> import re
>>
>> def interp(string, variables):
>>    globals = globals()
>>    for item in re.findall(r'\$\(([^{{]*)\)', string):
>>        string = string.replace('$(%s)' % item,
>>                            str(eval(item, globals, variables)))
>>    return string
>>
>> {0}
>> ", _content);
>>
>>            try
>>            {
>>                _engine = Python.CreateEngine();
>>                List<string> searchPaths = new
>> List<string>(_engine.GetSearchPaths());
>>                searchPaths.Add(
>>
>> Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
>>
>>                _engine.SetSearchPaths(searchPaths);
>>                ScriptSource source =
>>                    _engine.CreateScriptSourceFromString(script);
>>
>>                _script = source.Compile();
>>            }
>>            catch(SyntaxErrorException ex)
>>            {
>>                ExceptionOperations eo =
>>                    _engine.GetService<ExceptionOperations>();
>>                throw new ScriptedStringParseException(
>>                    eo.FormatException(ex), -1);
>>            }
>>
>> Then later I call:
>>
>> _script.DefaultScope.SetVariable("context",
>>                GenerateParameters(context));
>>            return _script.Execute<string>();
>>
>> The problem I am running into is that _script.Execute is that I am
>> getting an import exception on the "import re"
>>
>> re is a builtin module, so I am not sure why that is happening, does
>> the IronPython.Modules.dll need to be in the DLLs directory? I don't
>> remember having this issue previously.
>>
>> --
>> slide-o-blog
>> http://slide-o-blog.blogspot.com/
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>



-- 
slide-o-blog
http://slide-o-blog.blogspot.com/



More information about the Ironpython-users mailing list