Scott David Daniels wrote:

>     class Foo(object): # _Never_ use old-style without a reason
>         def __getitem__(self, index):
>             print index
>             if index < 3:
>                 return index * 5  # just to see
>             raise IndexError('Zapped') # The secret -- run out.

Another way is to make your object iterable -- read
up about the "iterator protocol".

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

Reply via email to