On 7/3/06, Michael Foord <[EMAIL PROTECTED]> wrote: > JoeSox wrote: > > On 7/2/06, Sanghyeon Seo <[EMAIL PROTECTED]> wrote: > > > >> 2006/7/3, JoeSox <[EMAIL PROTECTED]>: > >> > >>> What is the correct way to import an embedded module file(s) into a > >>> PythonEngine? (snip) > >>> > >> This is an interesting use case that could be done with PEP 302 import > >> hooks. In CPython it was introduced to allow importing modules from > >> .zip files, but in .NET setting it certainly makes sense to allow > >> importing modules embedded in the assembly, which I believe is not yet > >> possible with IronPython. > >> > > > > Interesting. Hopefully it will be supported in the future, until then > > I guess I will include my script files with my .dll, which seems odd > > to. > > > As a workaround, you could create your own module objects very easily > assuming you have the source code as a string. > > import imp > import sys > > newModule = imp.new_module(moduleName) > exec(sourceCode, newModule.__dict__) > sys.modules[moduleName] = newModule > > You *should* then be able to import from this module in the normal way. > (Unless I have made a mistake in the above code.)
I can get the resources as a string so I'll have to play around with that. Thanks good idea. -- Later, Joe _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
