for i in <instance>

Alex Martelli aleaxit at yahoo.com
Wed Jun 20 14:58:00 EDT 2001


"dan" <dan at eevolved.com> wrote in message
news:ou4Y6.35975$Vl2.1751749 at news20.bellglobal.com...
> what was overloaded in UserList so its items could be extracted when you
do
>
> for i in UserList([1,2,3])

Special method __getitem__.  It must raise IndexError when the index
parameter is too large.  (In Python 2.2, there will be a better way, but
up to 2.1, __getitem__ it is).


Alex






More information about the Python-list mailing list