Supporting index and key lookups in Python

Опубликовано: 07 Октябрь 2024
на канале: Python Morsels
133
12

Want square brackets (`like['this']`) to work on your objects in Python? You need to implement a `__getitem__` method!

https://pym.dev/supporting-index-and-...

Find more Python screencasts at https://pym.dev/screencasts/

00:00 Index and key lookups both use square brackets
00:31 Making square brackets work on your objects
01:10 Use _getitem_ to support index and key lookups

#python #oop