Is exec() also not used in python 2.7.1 anymore?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Oct 5 02:27:08 EDT 2011


En Tue, 04 Oct 2011 07:32:41 -0300, Wong Wah Meng-R32813  
<r32813 at freescale.com> escribió:

> Haha... yeah I reviewed the code, it is supposed to exposed some remote  
> methods locally (RMI proxy usage). However, I am not sure why what it  
> does is merely a pass.
>
> I commented out this code and haven't seen any negative implication. I  
> will look into this again if I am convinced the next error I see is due  
> to I commented out this code.

>>   exec('def %s(self, *args, **kw): pass'%methodStrName)

In case you convince yourself that defining this dynamic but empty  
function is really needed, you can avoid exec this way:

   def some_function(...)

     ...
     # instead of exec('def ...' % methodStrName)
     def empty_function(self, *args, **kw): pass
     empty_function.func_name = methodStrName
     ...
     # presumably methodStrName is referred somehow in
     # the remaining code block, or perhaps locals();
     # modify accordingly


-- 
Gabriel Genellina




More information about the Python-list mailing list