title: How to define [] for class in Python?
body: <p>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 <code>def []=()</code> construct in ruby, so that calling Python <code>obj['foo']</code> would actually call some <code>[](self, what)</code> method. How can I do that?</p>