function returns , but variable values has not changed in the interactive prompt

alex23 wuwei23 at gmail.com
Fri May 23 22:10:23 EDT 2008


On May 24, 5:04 am, davidj411 <davidj... at gmail.com> wrote:
> if you run execfile function to run a python script and that script
> has variables and functions, should't those variable change in the
> interactive prompt too?

Yes.

>cat a.py
a = 7
b = 'seven'

Python 2.5.1 (r251:54863, May  1 2007, 17:47:05) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> execfile('a.py')
>>> a
7
>>> b
'seven'

I think you need to show us the actual code in question, rather than
the odd behaviour you're experiencing. It's generally easier to debug
real code over blackboxing behaviour.



More information about the Python-list mailing list