I feel like this question has already been asked and answered, yet I couldn’t find anything on-topic, so excuse me if it is so. I want to define the behaviour of [] brackets when applied to class, similar to def []=() construct in ruby, so that calling Python obj['foo'] would actually call some [](self, what) method. How can I do that?
I feel like this question has already been asked and answered, yet I couldn’t
Share
It’s all in the docs:
__getitem__.