Re: On eval and its substitution of globals

2005-02-23 Thread Kent Johnson
Paddy wrote: I do in fact have the case you mention. I am writing a module that will manipulate functions of global variables where the functions are defined in another module. Would it be possible to have your functions take arguments instead of globals? That would seem to be a better design. Ke

Re: On eval and its substitution of globals

2005-02-23 Thread Paddy
Leif wrote: " If globals were deeply substituted when using eval, the program would presumably print "42\n24", which would be far from intuitive. If you limit the deep substitution to functions in the same module, you're creating a confusing special case. " I guess I need outside opinions on what

Re: On eval and its substitution of globals

2005-02-23 Thread Leif K-Brooks
Paddy wrote: I had to do as you suggest but I was thinking either it was a kludge, and there should be a 'deep' substitution of globals, or that there was a good reason for it to work as it does and some magician would tell me. If there was deep substitution of globals, how would functions importe

Re: On eval and its substitution of globals

2005-02-23 Thread Paddy
Thanks Kent for your reply. I had to do as you suggest but I was thinking either it was a kludge, and there should be a 'deep' substitution of globals, or that there was a good reason for it to work as it does and some magician would tell me. Oh, the third reason could be that it was first implimen

Re: On eval and its substitution of globals

2005-02-23 Thread Kent Johnson
Paddy wrote: Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries around knowledge of the globals() present when it was defined. (The .func_globals attribute)? When evaluated using eval(...) the embedded globals can be overridden w

Re: On eval and its substitution of globals

2005-02-22 Thread Paddy
I have had no reply so on revisiting this I thought I would re-submit it and point out that there is a question way down at the end :-) Thanks. = Original Post = Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries arou

On eval and its substitution of globals

2005-02-19 Thread Paddy
Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries around knowledge of the globals() present when it was defined. (The .func_globals attribute)? When evaluated using eval(...) the embedded globals can be overridden with the one