__getitem__ and __iter__ Implement Iteration : Getitem : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Getitem »

 

__getitem__ and __iter__ Implement Iteration


class stepper: 
     def __getitem__(self, i)
        return self.data[i

X = stepper(  )                       
X.data = "Spam" 

print X[1]                          
for item in X:                      
     print item,                    


print 'p' in X                      

print [for c in X]                

print map(None, X)                  

(a, b, c, d= X                    
print a, c, d 

print list(X), tuple(X)''.join(X

print X



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Getitem