Reinitializing the python interpreter form Java

Ype Kingma ykingma at accessforall.nl
Tue May 29 15:31:00 EDT 2001


"Andre M. Descombes" wrote:
> 
> Hi again Ype,
> 
> I think the problem of locals not changing was I was using
> PyFunction.__call__  which does not use the locals variable instead of
> PyFunction.exec which uses the locals.
> The problem I am encountering now, is apparently I can't pass any parameters
> with the exec method! Do you know if this can be done?
> 

For a second I was afraid this comes in the category
"you can't have your cake and eat it".

But you have control over the locals/globals so you could easily
pass something using PyInterpreter.set(), or just do it directly:

theLatestCopyOfYourGlobals['varName'] = valueYouWantToPass

before doing the exec. Using varName in your function should do the trick then.

Have fun,
Ype



More information about the Python-list mailing list