#NEWLINE# def __getitem__( self , item ) : #NEWLINE# #INDENT# if isinstance ( self , int ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return next ( islice ( self , item , ( item + 1 ) ) ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# raise IndexError ( 'index out of range' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( item , slice ) : #NEWLINE# #INDENT# return islice ( self , item . start , item . stop , item . step )