I've built Python for the iPhone app store (not jailbreak), http://www.sabonrai.com/PythonMath/http://www.google.com/url?sa=D&q=http://www.sabonrai.com/PythonMath/ .
Like embedding Python in another app, it uses PyRun_SimpleString() to execute commands entered by the user. For evaluating expressions, it uses PyEval_EvalCode() with the dictionary from the __main__ module.
My problem is that future division ("from __future__ import division") works within scripts executed by import or execfile() but not when entered interactively in the interpreter like this:
from __future__ import division a=2/3
When you do this, you get classic (integer) division, but if you enter it as follows, you get future (float) division.
from __future__ import division;a=2/3
It appears that the CO_FUTURE_DIVISION compiler flag is not being retained in the interpreter so that later commands get compiled without that flag.
I found a hint in comp.lang.pythonhttp://www.google.com/url?sa=D&q=http://groups.google.com/group/comp.lang.python/browse_thread/thread/13a90a9f6eb96c73/960e47f572a59711%3Flnk%3Dgst%26q%3Dco_future_division%23960e47f572a59711, but I don't see that PyRun_SimpleStringFlags returns the flags it uses. I guess I could watch for the user to enter the import command and set the flags on every subsequent call but seems really brittle to me.