exec/eval changed?

JB jimbag at kw.igs.net
Tue Nov 16 01:58:51 CET 1999


Michael Hudson wrote:
> 
> JB <jimbag at kw.igs.net> writes:
> 
> > Did the exec/eval statements change somehow in the 1.5 versions? I
> > have a script that did an eval( "some code", dict1, locals()) but
> > now it doesn't work. I've looked through the doc's but they are
> > little thin as to these statements. Any help is appreciated.
> 
> Well, eval("some code") is a syntax error. What are you trying to to
> do? We can't read minds here.
> 
> Regards,
> Michael

My apologies. I was thinking that the scoping for the 2nd and 3rd
parameters to the eval call had changed somehow and thus the code was
irrelevant to the example.

What I am trying to do is simple eval a string with python formatting
operations within and return the result. The code string is dynamic.
Basically: 

eval( "'The value of t is %(t)s' % t", self.private_dict, locals())

where t is in self.private_dict. The questions comes because this code
worked in python v1.5 but does not work in v 1.5.2 and I was curious if
there had been any changes to the scoping or to the eval/exec calls
themselves.

Sorry for the confusion.



-- 
-----------------------------------------------------------
Machine-Independent, adj.:
	Does not run on any existing machine.




More information about the Python-list mailing list