solve for X

Apr 06, 2007 13:31

class A(object ( Read more... )

Leave a comment

Comments 14

jerub April 7 2007, 01:29:55 UTC
Super Considered Useless.

Reply

mithrandi April 8 2007, 23:15:49 UTC
seems more like __init__ In Python Considered Sucktastic.

Reply

jerub April 9 2007, 00:08:49 UTC
This isn't an __init__ method being considered.

Reply

mithrandi April 9 2007, 00:14:24 UTC
Uhm, oops. In that case, this seems to be insanity; having a bunch of incompatible method signatures all in the same inheritance tree makes it rather impossible to sanely invoke all superclass versions, unless all the implementations cooperate. I'm not sure that this is a problem unique to Python, or to super(), but feel free to enlighten me.

Reply


One way to do it terrycojones April 7 2007, 04:34:27 UTC
Re: One way to do it glyf April 9 2007, 15:42:12 UTC
I think that this is the only correct solution (james indicates something similar in his age-old post about super()) but it also has a problem: it's not cooperative with classes that don't use this style.

The point of this post is that I am slowly realizing that it is impossible to correctly write mixins in Python. You can't really re-define methods lower in the inheritance hierarchy, you can only overload them, so mixins can pretty much never define __init__. Except, they also can't not define __init__, because then they inherit object's __init__, whose behavior is uncertain and changing.

Your post indicates that Python does provide nice support for inheritance diamonds, as long as the root of the diamond isn't "object".

Reply

Re: One way to do it mesozoic April 9 2007, 16:49:32 UTC
So doesn't that just mean you can write mixins, but you have to pass all arguments as a single keyword dict instead of as a tuple?

Reply

Re: One way to do it glyf April 9 2007, 17:01:58 UTC
A "mixin", almost by definition, shouldn't know anything about the properties of the classes it might be mixed in to. It might be necessary, practically speaking, to stipulate that it has to be mixed in to a new-style class or a classic class, since they are subtly incompatible inheritance models, but there should be a "right way" for either one, and I can't see it.

Reply


moshez April 7 2007, 06:52:56 UTC
Incompatibly changing method signatures is probably not a good idea.

Reply

glyf April 9 2007, 15:43:00 UTC
Every time you define __init__ you are incompatibly changing its signature.

Reply


Leave a comment

Up