I'm pretty sure I'd actually read the first 2 links you point to, but the
difference between __setattr__ and __setitem__ still never registered with
me -- perhaps partly because even the discussion of __setattr__ discusses
adding an entry to the "*dictionary* of instance attributes".
*MANY* thank
If you really want __setitem__ and not __setattr__, you should change the
base class to 'dict'. Or 'import UserDict' and use that for the base class.
On Aug 18, 2011 9:45 PM, "luvspython" wrote:
> I'm using Python 2.7 and the code below fails at the 'super' statement
> in the __setitem__ function
On Thu, Aug 18, 2011 at 7:44 PM, luvspython wrote:
> I'm using Python 2.7 and the code below fails at the 'super' statement
> in the __setitem__ function in the HistoryKeeper class. The error is:
> 'super' object has no attribute '_setitem__'
>
> Can anyone please tell me why and how to fix it?
luvspython gmail.com> writes:
> def __setitem__(self, item, value):
> super(HistoryKeeper, self).__setitem__(item, value)
object has no __setitem__. Are you looking for __setattr__?
>
> class Vehicle(HistoryKeeper):
> def __init__(self, tag, make, model):
> args = locals