From: rbill <rb...@di...> - 2002-02-01 04:31:17
|
Hi Matt, On Thu, 31 Jan 2002 Mat...@i2... wrote: > Whats the best way to do this in jython? I dunno about best, but I think something like this is common: // Set __name__ PyModule mod = imp.addModule("__main__"); interp.setLocals(mod.__dict__); > Currently what I do is shown below but I'm not sure if this is correct. > The reason for my apprehension is that when I just run an interactive > interpreter, I notice that sys.modules has a __main__ module, so I'm > wondering if I have to create that or something else special. > > PythonInterpreter interp = new PythonInterpreter(); > interp.set("__name__", "__main__"); > interp.execfile("myscript.py"); |