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

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun May 25 00:49:20 EDT 2008


En Fri, 23 May 2008 16:04:43 -0300, davidj411 <davidj411 at gmail.com> escribió:

> 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, they do:

C:\TEMP>type test.py
a = 123

def foo():
   return "hello"

(enter Python)
py> a = "Old value"
py> a
'Old value'
py> execfile("test.py")
py> a
123
py> foo()
'hello'

-- 
Gabriel Genellina




More information about the Python-list mailing list