I would like to replace lists in a program with another class in order to obtain more information on the underlying data. It's easy enough to do the following replacement:
list = ObservableList # new class, compatible with list
so that list([1, 2, 3])
returns an ObservableList
, but this does not affect expressions like [1, 2, 3]
or list comprehensions, which will still return a Python list. Is there any way to override these constructions so that they return an ObservableList
as well?