[Bf-committers] Patch: removing use of exec() and eval() from python source

Mathias Panzenböck grosser.meister.morti at gmx.net
Wed Oct 21 00:15:17 CEST 2009


On 10/20/2009 11:06 PM, Mathias Panzenböck wrote:
> 
> Even if the code is not changed to use the rna lookup function I think it should
> still be changed this way:
> exec("context.%s='%s'" % (self.path, self.value))
> ->
> exec("context.%s=%r" % (self.path, self.value))
>
> ...
> 
> Or in case python >= 2.5 can be assumed:
> exec("context.%s = %r if context.%s!=%r else %r" % (self.path, self.value_2,
> self.path, self.value_2, self.value_1))
> 

It just occurred to me that it should be possible to write:
exec("context.%s = self.value" % self.path)

and:
exec("context.%s = self.value_2 if context.%s!=self.value_2 else self.value_1" %
(self.path, self.path))

Which prevents the unnecessary conversion to and from strings of the values.

	-panzi


More information about the Bf-committers mailing list