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

Опубликовано: 06 Октябрь 2024
на канале: Sebastiaan Mathôt
16,979
509

(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__().