__setslice__ and classes derived from list

Michael Hoffman cam.ac.uk at mh391.invalid
Fri Sep 2 10:52:18 EDT 2005


Dave Opstad wrote:

> There's a workaround for this, namely to include this method:
> 
>     def __setslice__(self, i, j, seq):
>         self.__setitem__(slice(i, j), seq)
> 
> That way any custom code I need to include in __setitem__ doesn't have 
> to be duplicated in __setslice__. But just out of curiosity I thought 
> I'd ask the folks here if there's any other way of doing this?

I don't think so; at least it's what I've always done in the past. 
Perhaps you should submit a feature request? It must be time to get rid 
of __setslice__, if not now, then maybe by Python 3.0.
-- 
Michael Hoffman



More information about the Python-list mailing list