Re: [Python-Dev] python and super

2011-04-29 Thread Ethan Furman
Ricardo Kirkner wrote: I'll give you the example I came upon: I have a TestCase class, which inherits from both Django's TestCase and from some custom TestCases that act as mixin classes. So I have something like class MyTestCase(TestCase, Mixin1, Mixin2): ... now django's TestCase class

Re: [Python-Dev] python and super

2011-04-17 Thread Michael Foord
On 17 April 2011 02:48, Steven D'Aprano st...@pearwood.info wrote: Michael Foord wrote: On 15/04/2011 02:23, Steven D'Aprano wrote: [...] If we treat django's failure to use super as a bug, you want the Python language to work-around that bug so that: What you say (that this

Re: [Python-Dev] python and super

2011-04-17 Thread Nikolay Zakharov
16.04.2011 03:38, Greg Ewing пишет: Michael Foord wrote: consider the recently introduced problem caused by object.__init__ not taking arguments. This makes it impossible to use super correctly in various circumstances. ... It is impossible to inherit from both C and A and have all

Re: [Python-Dev] python and super

2011-04-17 Thread Greg Ewing
Mark Janssen wrote: I have to say it is quite strange to me that there is no distinction made between IS-A relationship and HAS-A relationships with regard to the issue of Inheritence. I'm not sure what you mean by that. Inheritance is (or should be) used only for is-a relationships. Misusing

Re: [Python-Dev] python and super

2011-04-16 Thread Steven D'Aprano
Michael Foord wrote: On 15/04/2011 02:23, Steven D'Aprano wrote: [...] If we treat django's failure to use super as a bug, you want the Python language to work-around that bug so that: What you say (that this particular circumstance could be treated as a bug in django) is true, however

Re: [Python-Dev] python and super

2011-04-16 Thread Mark Janssen
On Thu, Apr 14, 2011 at 7:09 AM, Ricardo Kirkner ricardokirk...@gmail.com wrote: I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it is currently a

Re: [Python-Dev] python and super

2011-04-16 Thread Mark Janssen
Argh! Sorry list. I meant to discard the post that was just sent. Please accept my humblest apologies... Mark ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] python and super

2011-04-15 Thread Greg Ewing
R. David Murray wrote: Why not? It seems more useful than using it for chaining, especially given the compiler hack in Python3. Because it's prone to doing the wrong thing if the class using it is ever involved in multiple inheritance. If you're expecting the call to go to a particular

Re: [Python-Dev] python and super

2011-04-15 Thread Michael Foord
On 15/04/2011 02:02, Greg Ewing wrote: Michael Foord wrote: What I was suggesting is that a method not calling super shouldn't stop a *sibling* method being called, but could still prevent the *parent* method being called. There isn't necessarily a clear distinction between parents and

Re: [Python-Dev] python and super

2011-04-15 Thread Michael Foord
On 15/04/2011 02:23, Steven D'Aprano wrote: Ricardo Kirkner wrote: I have a TestCase class, which inherits from both Django's TestCase and from some custom TestCases that act as mixin classes. So I have something like class MyTestCase(TestCase, Mixin1, Mixin2): ... now django's TestCase

Re: [Python-Dev] python and super

2011-04-15 Thread Mark Shannon
. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] python and super

2011-04-15 Thread Carl Meyer
On 04/15/2011 08:53 AM, Michael Foord wrote: If we treat django's failure to use super as a bug, you want the Python language to work-around that bug so that: What you say (that this particular circumstance could be treated as a bug in django) is true, Just as a side note: if there is a

Re: [Python-Dev] python and super

2011-04-15 Thread Michael Foord
On 15/04/2011 16:18, Carl Meyer wrote: On 04/15/2011 08:53 AM, Michael Foord wrote: If we treat django's failure to use super as a bug, you want the Python language to work-around that bug so that: What you say (that this particular circumstance could be treated as a bug in django) is true,

Re: [Python-Dev] python and super

2011-04-15 Thread Nick Coghlan
On Fri, Apr 15, 2011 at 11:30 PM, Michael Foord fuzzy...@voidspace.org.uk wrote: On 15/04/2011 02:02, Greg Ewing wrote: There isn't necessarily a clear distinction between parents and siblings. class A:  ... class B(A):  ... class C(A, B):  ... In C, is A a parent of B or a sibling

Re: [Python-Dev] python and super

2011-04-15 Thread Greg Ewing
Michael Foord wrote: consider the recently introduced problem caused by object.__init__ not taking arguments. This makes it impossible to use super correctly in various circumstances. ... It is impossible to inherit from both C and A and have all parent __init__ methods called correctly.

Re: [Python-Dev] python and super

2011-04-15 Thread Greg Ewing
Mark Shannon wrote: class A: pass class B(A): pass class C(A,B):pass Traceback (most recent call last): File stdin, line 1, in module TypeError: Cannot create a consistent method resolution order (MRO) for bases B, A All right, but this is okay: class C(B, A): pass Michael Foord wrote:

Re: [Python-Dev] python and super

2011-04-15 Thread Greg Ewing
Michael Foord wrote: But you have to be aware that because of the semantics of super, not calling up to your parents basically prevents those methods being used in the presence of multiple inheritance. No, it prevents them being used in the presence of super(). Multiple inheritance is still

[Python-Dev] python and super

2011-04-14 Thread Ricardo Kirkner
Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it is currently a requirement that all classes that are part of the mro chain behave and always call

Re: [Python-Dev] python and super

2011-04-14 Thread Benjamin Peterson
2011/4/14 Ricardo Kirkner ricardokirk...@gmail.com: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it is currently a requirement that all

Re: [Python-Dev] python and super

2011-04-14 Thread Antoine Pitrou
On Thu, 14 Apr 2011 08:15:10 -0500 Benjamin Peterson benja...@python.org wrote: 2011/4/14 Ricardo Kirkner ricardokirk...@gmail.com: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the

Re: [Python-Dev] python and super

2011-04-14 Thread Giampaolo Rodolà
:-) 2011/4/14 Antoine Pitrou solip...@pitrou.net On Thu, 14 Apr 2011 08:15:10 -0500 Benjamin Peterson benja...@python.org wrote: 2011/4/14 Ricardo Kirkner ricardokirk...@gmail.com: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super,

Re: [Python-Dev] python and super

2011-04-14 Thread Steven D'Aprano
Ricardo Kirkner wrote: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it is currently a requirement that all classes that are part of the mro chain

Re: [Python-Dev] python and super

2011-04-14 Thread Ronald Oussoren
On 14 Apr, 2011, at 15:09, Ricardo Kirkner wrote: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it is currently a requirement that all

Re: [Python-Dev] python and super

2011-04-14 Thread Michael Foord
On 14/04/2011 15:18, Ronald Oussoren wrote: On 14 Apr, 2011, at 15:09, Ricardo Kirkner wrote: Hi all, I recently stumbled upon an issue with a class in the mro chain not calling super, therefore breaking the chain (ie, further base classes along the chain didn't get called). I understand it

Re: [Python-Dev] python and super

2011-04-14 Thread Laura Creighton
I think that if you add this, people will start relying on it. Laura ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] python and super

2011-04-14 Thread Michael Foord
On 14/04/2011 16:02, Laura Creighton wrote: I think that if you add this, people will start relying on it. And the specific problem with that would be? Michael Laura -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others

Re: [Python-Dev] python and super

2011-04-14 Thread P.J. Eby
At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you *start* the chain by calling super then Python could ensure that all the methods are called for you. If an individual method doesn't call super then a

Re: [Python-Dev] python and super

2011-04-14 Thread Michael Foord
On 14/04/2011 16:34, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you *start* the chain by calling super then Python could ensure that all the methods are called for you. If an individual

Re: [Python-Dev] python and super

2011-04-14 Thread Ricardo Kirkner
Exactly what Michael said. Stopping the chain going upwards is one thing. Stopping it going sideways is another. On Thu, Apr 14, 2011 at 12:37 PM, Michael Foord fuzzy...@voidspace.org.uk wrote: On 14/04/2011 16:34, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo

Re: [Python-Dev] python and super

2011-04-14 Thread Daniel Urban
On Thu, Apr 14, 2011 at 16:18, Ronald Oussoren ronaldousso...@mac.com wrote: It would be odd to not call super in __init__, but for other methods not calling the superclass implementation is fairly common. Yes it is odd, that for example list.__init__ doesn't call super :-)

Re: [Python-Dev] python and super

2011-04-14 Thread Raymond Hettinger
On Apr 14, 2011, at 8:34 AM, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you *start* the chain by calling super then Python could ensure that all the methods are called for you. If an

Re: [Python-Dev] python and super

2011-04-14 Thread Michael Foord
On 14/04/2011 17:02, Raymond Hettinger wrote: On Apr 14, 2011, at 8:34 AM, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you *start* the chain by calling super then Python could ensure that

Re: [Python-Dev] python and super

2011-04-14 Thread Ronald Oussoren
On 14 Apr, 2011, at 18:10, Michael Foord wrote: On 14/04/2011 17:02, Raymond Hettinger wrote: On Apr 14, 2011, at 8:34 AM, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you *start* the

Re: [Python-Dev] python and super

2011-04-14 Thread Glyph Lefkowitz
On Apr 14, 2011, at 12:59 PM, Ronald Oussoren wrote: What would the semantics be of a super that (...) I think it's long past time that this move to python-ideas, if you don't mind. ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] python and super

2011-04-14 Thread Terrence Cole
On Thu, 2011-04-14 at 17:10 +0100, Michael Foord wrote: On 14/04/2011 17:02, Raymond Hettinger wrote: On Apr 14, 2011, at 8:34 AM, P.J. Eby wrote: At 03:55 PM 4/14/2011 +0100, Michael Foord wrote: Ricardo isn't suggesting that Python should always call super for you, but when you

Re: [Python-Dev] python and super

2011-04-14 Thread Ricardo Kirkner
What would the semantics be of a super that intentially calls all siblings? In particular what is the return value of such a call? The implementation can't know how to combine the implementations in the inheritance chain and should refuse the tempation to guess. I'll give you the example

Re: [Python-Dev] python and super

2011-04-14 Thread Ethan Furman
Ricardo Kirkner wrote: What would the semantics be of a super that intentially calls all siblings? In particular what is the return value of such a call? The implementation can't know how to combine the implementations in the inheritance chain and should refuse the tempation to guess. I'll

Re: [Python-Dev] python and super

2011-04-14 Thread Raymond Hettinger
On Apr 14, 2011, at 3:32 PM, Ricardo Kirkner wrote: What would the semantics be of a super that intentially calls all siblings? In particular what is the return value of such a call? The implementation can't know how to combine the implementations in the inheritance chain and should

Re: [Python-Dev] python and super

2011-04-14 Thread Greg Ewing
Ricardo Kirkner wrote: My question is, shouldn't/wouldn't it be better, if python took ownership of that part, and ensured all classes get called, even if some class misbehaved? I don't think so. If a class isn't designed to be part of a super chain, there are likely to be other issues that

Re: [Python-Dev] python and super

2011-04-14 Thread Greg Ewing
P.J. Eby wrote: It's perfectly sensible and useful for there to be classes that intentionally fail to call super(), and yet have a subclass that wants to use super(). One such case is where someone is using super() in a single-inheritance environment as a way of not having to write the base

Re: [Python-Dev] python and super

2011-04-14 Thread Greg Ewing
Michael Foord wrote: What I was suggesting is that a method not calling super shouldn't stop a *sibling* method being called, but could still prevent the *parent* method being called. There isn't necessarily a clear distinction between parents and siblings. class A: ... class B(A): ...

Re: [Python-Dev] python and super

2011-04-14 Thread Steven D'Aprano
Ricardo Kirkner wrote: I have a TestCase class, which inherits from both Django's TestCase and from some custom TestCases that act as mixin classes. So I have something like class MyTestCase(TestCase, Mixin1, Mixin2): ... now django's TestCase class inherits from unittest2.TestCase, which

Re: [Python-Dev] python and super

2011-04-14 Thread Greg Ewing
Raymond Hettinger wrote: If an external non-cooperative class needs to be used, then it should be wrapped in a class that makes an explicit __init__ call to the external class and then calls super().__init__() to continue the forwarding. I don't think it's as simple as that. Isn't that

Re: [Python-Dev] python and super

2011-04-14 Thread R. David Murray
On Fri, 15 Apr 2011 12:58:14 +1200, Greg Ewing greg.ew...@canterbury.ac.nz wrote: P.J. Eby wrote: It's perfectly sensible and useful for there to be classes that intentionally fail to call super(), and yet have a subclass that wants to use super(). One such case is where someone is