python multiple inheritance passing arguments to constructors using super
Consider the following snippet of python code
Consider the following snippet of python code
I’ve recently discovered (via StackOverflow) that to call a method in a base class I should call: super([[derived class]], self).[[base class method]]() That’s fine, it works. However, I find myself often copying and pasting between classes when I make a change and frequently I forget to fix the derived class argument to the super() function. … Read more
This question already has answers here: Why does using `arg=None` fix Python’s mutable default argument issue? (5 answers) Closed last month. I’ve found a strange issue with subclassing and dictionary updates in new-style classes: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 >>> class a(object): … def __init__(self, props={}): … Read more
It’s often stated that super should be avoided in Python 2. I’ve found in my use of super in Python 2 that it never acts the way I expect unless I provide all arguments such as the example: super(ThisClass, self).some_func(*args, **kwargs) It seems to me this defeats the purpose of using super(), it’s neither more … Read more