List callbacks?

前端 未结 3 423
离开以前
离开以前 2021-01-05 00:50

Is there any way to make a list call a function every time the list is modified?

For example:

>>>l = [1, 2, 3]
>>>def          


        
3条回答
  •  长情又很酷
    2021-01-05 01:28

    I'm almost certain this can't be done with the standard list.

    I think the cleanest way would be to write your own class to do this (perhaps inheriting from list).

提交回复
热议问题