The Python Papers

The Python Papers

How to Override a List Attribute’s Append() Method in Python

Mike Driscoll's avatar
Mike Driscoll
Jan 08, 2025
∙ Paid

I had a use-case where I needed to create a class that had an attribute that was a Python list. Seems simple, right? The part that made it complicated is that I needed to do something special when anything was appended to that attribute. Watching for attribute changes don’t work the same way for lists as it would for a string.

I tried a lot of different …

User's avatar

Continue reading this post for free, courtesy of Mike Driscoll.

Or purchase a paid subscription.
© 2026 Mike Driscoll · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture