Python question

John D. lists at webcrunchers.com
Mon Sep 29 18:03:34 EDT 2003


#This program gives: "SyntaxError: unqualified exec is not allowed
#  in function _ it contains a nested function with free variables"

#I understand this is a scope problem(?)
#I don't understand why this fails. It should be perfectly obvious
#what z is equal to when exec sees it. Furthermore, it shouldn't care
#about any other variables since it uses no others, and writes to none.

#What does this mean? What is "unqualified" and how do I qualify it?
#Are the free variables d or z? Is 'free' a boolean state or are there
#other related qualities? 
#What are the various work-arounds? 

#I am using d as a global dictionary to store all my variables.

d={} #Doesn't matter if I have d here
def myfunc():
	z='print'
	exec(z)
	d={} #or here...
	def setvar():
		d[0]=1
		return







More information about the Python-list mailing list