Scope of InteractiveInterpreter?

Ulrich Petri ulope at gmx.de
Thu Aug 21 03:55:42 EDT 2003


Kris Caselden" <google at hanger.snowbird.net> schrieb im Newsbeitrag
news:abc3fdd3.0308202339.6a8fed9b at posting.google.com...
> I'm using the InteractiveInterpreter to run some source, but the data
> generated doesn't seem to be available in the scope of the parent.
>
> For instance, I tried
>
> lines = infile.open('data.py','r').readlines()
> ii = InteractiveInterpreter({'__name__': '__main__', '__doc__': None})
> for line in lines:
>     ii.runsource(line)
>
> but the data objects in data.py don't seem to exist when I try and
> manipulate them later in the script. Is what I'm trying to do
> possible? Am I on the right track?

Try:
-------
import data

print data.whatever
--------
instead

Cu Ulrich






More information about the Python-list mailing list