1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python 3: hook list & dict changes

Discussão em 'Python' iniciado por Stack, Setembro 11, 2025.

  1. Stack

    Stack Membro Participativo

    My app relies on list and dict data structures for maintaining current state. Now I need to track whenever element is added/removed from list or dict data changes. I've googled and found out that there are collections.abc.Sequence (for list) and collections.abc.MutableMapping (for dict), but they're very limited and result can't be used instead of list/dict (append, clear, ...). I've been thinking about some proxy class that'll forward calls and provide hooks to be called before/after some method is forwarded, but didn't find anything that even looks like in.

    So my question is: how do I hook mutators of given structures? Is there something I don't know?

    Continue reading...

Compartilhe esta Página