From: <bc...@wo...> - 2001-03-20 16:58:20
|
[Jayson S Baird] >Hiho all, > > I know this will seem a bit odd, but in a research project, I'm using >python as the embedded scripting language from java. The hard part is, we >need to use the curses library. Python, of course has a curses module, but >can iot be used with Jython? No. AFAIK, nobody have made a curses library for java. >Another question is, can another file, or >string buffer(python code), be put in the namespace so an import can be >used from another python script? I know it seems odd, but any redesign >suggestions or help would be appreciated. Maybe I'm not parsing your question correctly, but you can fake a module import with code like this: --------------- BEGIN --------------- import new, sys s = """ def bar(): print 'bar' """ c = compile(s, "dummy", "exec") m = new.module("dummy") exec c in m.__dict__, m.__dict__ sys.modules['dummy'] = m --------------- END --------------- Later and in a different module, you can import the faked "dummy" module with code like this: import dummy dummy.bar() regards, finn |