Home » Science & Technology » Python tricks: Using magic (dunder) functions to create list-like objects

Python tricks: Using magic (dunder) functions to create list-like objects

Written By Sebastiaan Mathôt on Tuesday, Nov 28, 2017 | 05:27 PM

 
(For more, visit https://pythontutorials.eu !) In this video I demonstrate how you can use magic functions, sometimes called dunder (double-underscore) functions, to support special list-like syntax in your own objects. Specifically, I will demonstrate __len__(), __contains__(), and __getitem__().