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


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0