Re: [Jython-dev] imports with parser type eval
by Samuele Pedroni other posts by this author
Oct 21 2004 11:59PM messages near this date
[Jython-dev] Broken link
|
Re: [Jython-dev] imports with parser type eval
Samuele Pedroni wrote:
> Mark Proctor wrote:
>
> > Yes if I could pass the imports via the dict that would be great then
> > I can continue to use Py.runCode - which I assume is cheaper than
> > having lots of PythonInterpretors - anyone care to explain the inner
> > workings here? I know how to bind a single class type via the dict but
> > not how to do it for statements like "from module import *"
> >
>
> if I understand you have this situation, various instances of
>
> <imports>
> suite with imports?
> </imports>
>
> <functions>
> suite with func defs
> </functions>
>
> <condition>
> expr
> </contidtion>
>
> <consequence>
> suite
> </consequence>
>
> you execute imports and functions in a dict, you store it away,
>
> then you compile condition and consequence to code and store those too,
>
> and when necessary you execute them passing the parameters as locals and
> the dict populated in the first step as globals.
an alternative for condition and consequence is to transform their code
to functions defs if you know the involved parameter names:
def _cond(parm0,...):
return <contion-expr>
def _cons(parm0,...):
<consequence-suite>
you would execute this code with empty locals and the shared globals,
then extract from the locals _cond and _cons and invoke them using the
PyObject.__call__ family of methods.
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Jython-dev mailing list
Jython-dev@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-dev
|