exec considered harmful

Quinn Dunkan quinn at regurgitate.ugcs.caltech.edu
Wed Jul 25 13:12:48 EDT 2001


On 25 Jul 2001 09:21:22 +0200, Harald Kirsch <kirschh at lionbioscience.com> wrote:
>"Nick Perkins" <nperkins7 at home.com> writes:
>
>> why exec(), when you can import?
>[snip]
>>   I have done a fair bit of Python, and *never* used exec() or eval() )

I've used exec (no parens, it's a statement not a function) many times.
I like to include an option in interactive programs to drop into a python
REPL.  Then when the program starts acting weird, I can drop into python and
inspect the internal state, pickle and marshal some bits as an ad hoc core
dump, and maybe get it working enough to save and quit gracefully.  Until
python gets a debugger that can attach to a running process, it's quite handy.



More information about the Python-list mailing list