Python 2.7.x - problem with obejct.__init__() not accepting *args and **kwargs
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed May 15 22:06:11 EDT 2013
On Wed, 15 May 2013 13:16:09 +0100, Oscar Benjamin wrote:
> I don't generally use super()
Then you should, especially in Python 3.
If you're not using super in single-inheritance classes, then you're
merely making your own code harder to read and write, and unnecessarily
difficult for others to use with multiple-inheritance.
If you're not using super in multiple-inheritance[1] classes, then your
code is probably buggy.
There really is no good reason to avoid super in Python 3.
> but I did see some advice about it in this article:
> https://fuhm.net/super-harmful/
It's not a good article. The article started off claiming that super was
harmful, hence the URL. He's had to back-pedal, and *hard*. The problem
isn't that super is harmful, it is that the problem being solved --
generalized multiple inheritance -- is inherently a fiendishly difficult
problem to solve. Using super and cooperative multiple inheritance makes
it a merely difficult but tractable problem.
The above article is useful to see the sorts of issues that can come up
in multiple inheritance, and perhaps as an argument for avoiding MI
(except in the tamed versions provided by mixins or straits). But as an
argument against super? No.
A much better article about super is:
http://rhettinger.wordpress.com/2011/05/26/super-considered-super/
> From the conclusion:
> "Never use positional arguments in __init__ or __new__. Always use
> keyword args, and always call them as keywords, and always pass all
> keywords on to super."
Even that advice is wrong. See Super Considered Super above.
[1] To be precise: one can write mixin classes without super, and
strictly speaking mixins are a form of multiple inheritance, but it is a
simplified version of multiple inheritance that avoids most of the
complications.
--
Steven
More information about the Python-list
mailing list