12.04.21 19:01, Andreas R Maier пише:
> Hi,
> I have written some classes that represent immutable views on collections 
> (see "immutable-views" package on Pypi).
> 
> Currently, these view classes inherit from the abstract collection classes 
> such as Mapping, Sequence, Set. However, they implement the read-only methods 
> of dict, list and set, which provides some more methods compared to the 
> abstract collection classes. For example, class "dict" provides copy() or 
> __reversed__() and the newer OR-operator methods all of which are not defined 
> on the abstract class "Mapping".
> 
> Note that the view classes do not provide any of the modifying methods of 
> "dict" and "list", because after all the views are supposed to be immutable.
> 
> My question is, should the dict view class inherit from Mapping or from dict, 
> and likewise, should the list view class inherit from Sequence or from list?

If it is a view, and represents a data stored in another object, it
cannot be a subclass of concrete collection class.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to