Re: use of exec()

2012-10-20 Thread lars van gemerden
On Saturday, October 20, 2012 4:00:55 AM UTC+2, Chris Angelico wrote: > On Sat, Oct 20, 2012 at 10:43 AM, lars van gemerden > > wrote: > > > Do you have any ideas about to what extend the "lambda" version of the code > > (custom code is only the 'body' of the lambda function) has the same issue

Re: use of exec()

2012-10-19 Thread Chris Angelico
On Sat, Oct 20, 2012 at 10:43 AM, lars van gemerden wrote: > Do you have any ideas about to what extend the "lambda" version of the code > (custom code is only the 'body' of the lambda function) has the same issues? The lambda version definitely has the same issues. You can do pretty much anythi

Re: use of exec()

2012-10-19 Thread lars van gemerden
On Thursday, October 18, 2012 5:16:50 PM UTC+2, Chris Angelico wrote: > On Fri, Oct 19, 2012 at 2:00 AM, lars van gemerden > wrote: > > > I get your point, since in this case having the custom code option makes > > the system a whole lot less complex and flexible, i will leave the option > > i

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 2:00 AM, lars van gemerden wrote: > I get your point, since in this case having the custom code option makes the > system a whole lot less complex and flexible, i will leave the option in. The > future customer will be informed that they should handle the security around

Re: use of exec()

2012-10-18 Thread lars van gemerden
On Thursday, October 18, 2012 4:29:45 PM UTC+2, Chris Angelico wrote: > On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden > wrote: > > > Thanks, Chris, > > > > > > That works like a charm (after replacig "return ns.function" with "return > > ns['function']" ;-) ). > > > > Err, yes, I forg

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Fri, Oct 19, 2012 at 1:07 AM, lars van gemerden wrote: > Thanks, Chris, > > That works like a charm (after replacig "return ns.function" with "return > ns['function']" ;-) ). Err, yes, I forget sometimes that Python doesn't do that. JavaScript and Pike both let you (though Pike uses -> instea

Re: use of exec()

2012-10-18 Thread lars van gemerden
On Thursday, October 18, 2012 1:49:35 PM UTC+2, Chris Angelico wrote: > On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden > > wrote: > > > NameError: name 'function' is not defined > > > > > > which seems an odd error, but i think some global variable is necessary for > > this to work (if i

Re: use of exec()

2012-10-18 Thread Chris Angelico
On Thu, Oct 18, 2012 at 10:41 PM, lars van gemerden wrote: > NameError: name 'function' is not defined > > which seems an odd error, but i think some global variable is necessary for > this to work (if i put in globals() instead of {}, it works). The def statement simply adds a name to the curre

use of exec()

2012-10-18 Thread lars van gemerden
I am trying to implement a way to let users give a limited possibility to define functions in text, that wille be stored and executed at a later time. I use exec() to transform the text to a function. The code is as follows: class code(str): def __call__(self, *args): try: