Evan Simpson <[EMAIL PROTECTED]> writes:
> 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
> >>>
>
[snip]
> [Is] there a way to do this (intercept global variable
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Evan Simpson wrote:
>
>> 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
>> >>>
Evan Simpson wrote:
> 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
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