__getitem__ used in a for loop : getitem « Class « Python Tutorial






class MyRange:
   def __init__( self, start, stop, step ):
      self.sequence = range( start, stop, step )

   def __getitem__( self, subscript ):
      return self.sequence[ subscript ]








11.19.getitem
11.19.1.__getitem__ used in a for loop
11.19.2.__getitem__ and __iter__ Implement Iteration
11.19.3.__getitem__ Intercepts Index References