In Python 2.4 the following works:

>>> class G(dict):
...   def __getitem__(self, k):
...     return 'K' + k
...
>>> g = G()
>>> exec 'print x, y, z' in g
Kx Ky Kz
>>>

...while in Python 2.3 it fails with NameError: name 'x' is not defined. Is this an "accidental feature", or can I count on this working in future versions of Python? For that matter, is there a way to do this (intercept global variable accesses) in Python 2.3?

Cheers,

Evan @ 4-am

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to