Jacek Generowicz wrote:
> Inspecting the implementation of execfile suggests to me that the
> assignments are performed by a hard-wired call to PyDict_SetItem, in
> the opcode implementations, so it looks like ideas based on giving
> execfile a globals dictionary with an instrumented __setitem__ are
> probably doomed to failure.
For Python 2.4 here is evidence against that assumption:
$ cat config.py
a = 42
b = "so what"
>> class Dict(dict):
... def __setitem__(self, k, v):
... print k, "->", v
... dict.__setitem__(self, k, v)
...
>>> execfile("config.py", Dict())
a -> 42
b -> so what
We are all doomed to succeed, then...
Peter
--
http://mail.python.org/mailman/listinfo/python-list