In article <[EMAIL PROTECTED]>,
 Leif K-Brooks <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] wrote:
> > Why doesn't this work?
> > 
> > 
> >>>>def foo(lst):
> > 
> > ...   class baz(object):
> > ...     def __getitem__(cls, idx): return cls.lst[idx]
> > ...     __getitem__=classmethod(__getitem__)
> > ...   baz.lst = lst
> > ...   return baz
> > ...
> > 
> > I thought x[y] and x.__getitem__(y) were supposed to always be
> > synonymous.
> 
> No, with new-style classes, x[y] and type(x).__getitem__(y) are 
> synonymous.

Ah.

Did you mean type(x).__getitem__(x,y)?

And where is this documented?

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

Reply via email to