For example
class Test: def __getitem__(self,key): return 0 a = Test() print a[2] print a["hello"]We can modify its behavior in the method.
More information about python attributes at: http://docs.python.org/reference/datamodel.html
|
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time.
Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more... |
class Test: def __getitem__(self,key): return 0 a = Test() print a[2] print a["hello"]We can modify its behavior in the method.
No comments:
Post a Comment