Re: Re[4]: [A-A-P-develop] Implementing scopes
Brought to you by:
vimboss
From: Bram M. <Br...@mo...> - 2003-03-17 20:39:28
|
Steve Howe wrote: > I've tried some code (attached, test1.py) but it won't work: exec > really looks for a dict type argument, even if our class emulates one. I'm glad you verified this. My attempts to convince exec to work with anything but a real dictionary have failed. > I thought exec could use the type() function to verify the type of the > argument sent to exec, and I I've tried overriding the built-in type() > function: [...] > ... but it didn't work (exec must use some other function to check the > arg type, or keep a reference to the original type() function). It might use a low-level C function to check the type. > This leads us to try another more static implementation (test2.py), > which while is not as elegant as test1.py, should deal with it. But this will evaluate all variables in the expression in the same scope, while some variables may come from another scope. We really need "exec" anyway. > If we, however, manage to trick exec()/eval() into using a UserDict > module, we probably should use implementation from test1.py. I'll look > more into this but I think it might not be possible at all... Hopefully you find some way to do this. Perhaps looking at the Python source code reveals a trick? -- From "know your smileys": :.-( Crying /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html /// |