Class : Class getitem : Class PYTHON examples


PYTHON examples » Class » Class getitem »

 

Class


Class: __getitem__ demo


class indexer:
     def __getitem__(self, index):
         return index ** 2

X = indexer()
print X[2]                        # X[icalls __getitem__(X, i)

for i in range(5)
     print X[i],             

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


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


PYTHON examples

 Navioo Class
» Class getitem