Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-17 Thread Devin Jeanpierre
On Tue, Feb 17, 2015 at 7:31 AM, Steven D'Aprano wrote: > On Mon, Feb 16, 2015 at 07:10:21PM -0800, Devin Jeanpierre wrote: >> On Mon, Feb 16, 2015 at 6:15 PM, Steven D'Aprano wrote: >> > Here is a fork of that recipe. It uses an inner class for the new >> > namedtuple class. The only thing which

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-17 Thread Steven D'Aprano
On Mon, Feb 16, 2015 at 07:10:21PM -0800, Devin Jeanpierre wrote: > On Mon, Feb 16, 2015 at 6:15 PM, Steven D'Aprano wrote: > > Here is a fork of that recipe. It uses an inner class for the new > > namedtuple class. The only thing which needs exec is the __new__ method. > > > > http://code.actives

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread Devin Jeanpierre
On Mon, Feb 16, 2015 at 7:20 PM, Cameron Simpson wrote: > One might use exec() to use code that is valid in one python version but not > another, when you need your program to run in both i.e. to get code that is > syntacticly invalid in one version, but to use it (conditionally) in another > vers

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread Cameron Simpson
On 16Feb2015 19:10, Devin Jeanpierre wrote: On Mon, Feb 16, 2015 at 6:15 PM, Steven D'Aprano wrote: Here is a fork of that recipe. It uses an inner class for the new namedtuple class. The only thing which needs exec is the __new__ method. http://code.activestate.com/recipes/578918-yet-another

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread Devin Jeanpierre
On Mon, Feb 16, 2015 at 6:15 PM, Steven D'Aprano wrote: > Here is a fork of that recipe. It uses an inner class for the new > namedtuple class. The only thing which needs exec is the __new__ method. > > http://code.activestate.com/recipes/578918-yet-another-namedtuple/ > > This demonstrates a powe

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread Steven D'Aprano
On Mon, Feb 16, 2015 at 01:52:16PM -0600, boB Stepp wrote: > I have heard periodically about the potential evils of using exec() > and eval(), including today, on this list. I gather that the first > requirement for safely using these functions is that the passed > argument MUST be from a trusted

Re: [Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread Danny Yoo
On Mon, Feb 16, 2015 at 11:52 AM, boB Stepp wrote: > I have heard periodically about the potential evils of using exec() > and eval(), including today, on this list. I gather that the first > requirement for safely using these functions is that the passed > argument MUST be from a trusted source.

[Tutor] What are *appropriate* uses for exec() and eval() ?

2015-02-16 Thread boB Stepp
I have heard periodically about the potential evils of using exec() and eval(), including today, on this list. I gather that the first requirement for safely using these functions is that the passed argument MUST be from a trusted source. So what would be examples where the use of these functions