0

I hope I make it clear in the title. I'm trying to inherit from list, and I want some of my own methods to be called when an instance of my class is created. However, I can't override list.__init__ since that would make me unable to use list's original methods. How can I accomplish this?

1 Answer 1

2

Simply call super.__init__ before / after you call your own methods:

class CustomList(list):
    def __init__(self, *args):
        super(CustomList, self).__init__(*args)
        # call your own methods here
1
  • Wow, great. Thank you!
    – aIKid
    Jul 31, 2015 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.