Leif Brooks:
>with new-style classes, x[y] and type(x).__getitem__(y) are
>synonymous.

Yes, but check the discussion around SF789262. The call ``x[y]`` is
converted to  ``type(x).__getitem__(x,y)``
*only if* ``__getitem__`` is explicitely defined in ``type(x)``. If
``type(x)`` does not define ``__getitem__`` directly, but only
indirectly via delegation (i.e. overriding ``__getattribute__``),
then the second form (i.e. ``type(x).__getitem__(x,y)``) works but
not the first one (i.e. ``x[y]`` raises an error).

                       Michele Simionato

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

Reply via email to