The Python Papers

The Python Papers

Share this post

The Python Papers
The Python Papers
How to Override a List Attribute’s Append() Method in Python
Copy link
Facebook
Email
Notes
More

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

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

Share this post

The Python Papers
The Python Papers
How to Override a List Attribute’s Append() Method in Python
Copy link
Facebook
Email
Notes
More
2
Share

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 …

Keep reading with a 7-day free trial

Subscribe to The Python Papers to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Mike Driscoll
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More