Defining __getitem__() in a class that inherits from (dict)

Tobiah toby at rcsreg.com
Wed Mar 9 00:25:04 EST 2005


My appreciation for your responses is not
easily imparted through text.  Thank You.

Steven Bethard wrote:
> Michael Hoffman wrote:
> 
>> Tobiah wrote:
>>
>>> If within the __getitem__ method I attempt
>>> to get an item from self, the __getitem__ method is
>>> called in an infinite recursion.
>>
>>
>> You need to explicitly use dict.__getitem__(self, key) instead of
>> using self[key] directly.
> 
> 
> or super(bar, self).__getitem__(key)
> 
> STeVe



More information about the Python-list mailing list