"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
>> >>>
>>
>> ...while in Python 2.3 it fails with NameError: name 'x' is not defined.

> I don't think he added this purely by accident,

As I remember, Raymond H.  was responding to a request by someone who ran 
into that exception.  In general, functions accepting a base class should 
at least accept subclasses of that baseclass.

tjr



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

Reply via email to