def __setitem__ ( self , * args , * * kwargs ) : super ( History , self ) . __setitem__ ( * args , * * kwargs ) if len ( self ) > self . size : self . popitem ( False )
pop will remove popped up items in python
Cut if needed .
def __setitem__(self, *args, **kwargs):
        """ Cut if needed. """
        super(History, self).__setitem__(*args, **kwargs)
        if len(self) > self.size:
            self.popitem(False)