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 st...@pearwood.info 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 st...@pearwood.info wrote: Here is a fork of that recipe. It uses an inner class for the new

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 st...@pearwood.info 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.

[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

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 robertvst...@gmail.com 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

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 st...@pearwood.info 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

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 Devin Jeanpierre
On Mon, Feb 16, 2015 at 7:20 PM, Cameron Simpson c...@zip.com.au 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

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

2015-02-16 Thread Cameron Simpson
On 16Feb2015 19:10, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Mon, Feb 16, 2015 at 6:15 PM, Steven D'Aprano st...@pearwood.info 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.