Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Michele Simionato
On Jul 31, 5:08 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: I have read Michelle Simionato's articles on super in Python. One l please! I am a man! ;-) But Michelle is wrong to conclude that the problem lies with the concept of *superclass*. The problem lies with the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Paul Rubin
Michele Simionato michele.simion...@gmail.com writes: I am actually more radical than that. From http://www.artima.com/weblogs/viewpost.jsp?thread=237121: In this series I have argued that super is tricky; I think nobody can... When I look at that URL, I see a Java stack dump:

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Jean-Michel Pichavant
Paul Rubin wrote: Michele Simionato michele.simion...@gmail.com writes: I am actually more radical than that. From http://www.artima.com/weblogs/viewpost.jsp?thread=237121: In this series I have argued that super is tricky; I think nobody can... When I look at that URL, I see a Java

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Steven D'Aprano
On Sun, 01 Aug 2010 23:15:11 -0700, Michele Simionato wrote: On Jul 31, 5:08 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: I have read Michelle Simionato's articles on super in Python. One l please! I am a man! ;-) My apologies. You'd think I would know the difference

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Mark Lawrence
On 02/08/2010 10:23, Jean-Michel Pichavant wrote: Paul Rubin wrote: Michele Simionato michele.simion...@gmail.com writes: I am actually more radical than that. From http://www.artima.com/weblogs/viewpost.jsp?thread=237121: In this series I have argued that super is tricky; I think nobody

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Mark Lawrence
On 02/08/2010 07:15, Michele Simionato wrote: On Jul 31, 5:08 am, Steven D'Apranost...@remove-this- cybersource.com.au wrote: I have read Michelle Simionato's articles on super in Python. One l please! I am a man! ;-) Please prove it, get your bits out!!! :) M. Simionato

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Ethan Furman
Steven D'Aprano wrote: On Sat, 31 Jul 2010 13:29:25 +, Brian Victor wrote: Steven D'Aprano wrote: On Sat, 31 Jul 2010 14:25:39 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: A / \ C B \ / D / \ E F Yes, a super call might jog left from C to

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread donn
On 02/08/2010 17:35, Mark Lawrence wrote: aka the colon. :) Ha. This is a case of the colon being the appendix! \d -- http://mail.python.org/mailman/listinfo/python-list

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-02 Thread Mark Lawrence
On 02/08/2010 17:53, donn wrote: On 02/08/2010 17:35, Mark Lawrence wrote: aka the colon. :) Ha. This is a case of the colon being the appendix! \d Is there a better newsgroup in the world than c.l.py? No! Kindest regards. Mark Lawrence. --

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-01 Thread Steven D'Aprano
On Sat, 31 Jul 2010 13:29:25 +, Brian Victor wrote: Steven D'Aprano wrote: On Sat, 31 Jul 2010 14:25:39 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: A / \ C B \ / D / \ E F Yes, a super call might jog left from C to B, but only when

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-08-01 Thread Gregory Ewing
Steven D'Aprano wrote: super(C, self) shouldn't be interpreted as call C's superclasses from self. It means starting just after C in the MRO, call self.__class__'s superclasses. My contention is that nobody has any chance of guessing what it does based on the name super. Superness doesn't

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Steven D'Aprano
On Fri, 30 Jul 2010 21:40:21 -0600, Ian Kelly wrote: I have to chime in and agree that the name super is problematic. I'm reading this thread with a sense of alarm because I apparently never read the super() documentation too closely (why would I? Oh, it just accesses an attribute from a

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Brian Victor
Steven D'Aprano wrote: On Sat, 31 Jul 2010 14:25:39 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: A / \ C B \ / D / \ E F Yes, a super call might jog left from C to B, but only when being called from one of the lower classes D-F. That's

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Ian Kelly
On Sat, Jul 31, 2010 at 4:22 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 30 Jul 2010 21:40:21 -0600, Ian Kelly wrote: I have to chime in and agree that the name super is problematic. I'm reading this thread with a sense of alarm because I apparently never read the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Gregory Ewing
Steven D'Aprano wrote: Assuming you accurately tell it the current class, can you give an example where super() doesn't refer to a superclass of the current class? I think we're all confusing each other in this discussion by not being clear enough about what we mean by the current class. In

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Gregory Ewing
Ian Kelly wrote: super(type[, object-or-type]) ... The __mro__ attribute of the type lists the method resolution search order used by both getattr() and super(). The attribute is dynamic and can change whenever the inheritance hierarchy is updated. That explanation does seem to be

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Carl Banks
On Jul 31, 11:16 am, Ian Kelly ian.g.ke...@gmail.com wrote: On Sat, Jul 31, 2010 at 4:22 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 30 Jul 2010 21:40:21 -0600, Ian Kelly wrote: I have to chime in and agree that the name super is problematic. I'm reading

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-31 Thread Carl Banks
On Jul 31, 8:48 pm, Carl Banks pavlovevide...@gmail.com wrote: When you have a class you that don't anything about the implementation of, that is NOT the place for inheritance. And, just to be clear, if the class is explicity documented as being subclassable and the documentation states the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Gregory Ewing
Steven D'Aprano wrote: super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. That's not strictly true. It will call a method belonging to some class in the mro of self, but that class is

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Gregory Ewing
Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: mro would have been the proper name for super. That's your opinion. In any case, whether super() was called super() or mro() or aardvark() makes no difference to the functionality or whether it is

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: [snip] As someone already said in this list, the main problem with super is that it tends to refer to the superclass method while in fact it calls the next MRO method. Why do you think that is a

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Steven D'Aprano
On Fri, 30 Jul 2010 19:35:52 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. That's not strictly true. It will call a method

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Steven D'Aprano
On Fri, 30 Jul 2010 19:37:29 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: mro would have been the proper name for super. That's your opinion. In any case, whether super() was called super() or mro() or aardvark()

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Fri, 30 Jul 2010 19:37:29 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: mro would have been the proper name for super. That's your opinion. In any case, whether

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Hrvoje Niksic
Gregory Ewing greg.ew...@canterbury.ac.nz writes: I think the point is that the name is misleading, because it makes it *sound* like it's going to call a method in a superclass, when it fact it might not. That is indeed confusing to some people, especially those who refuse to to accept the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Raymond Hettinger
On Jul 25, 5:30 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Raymond Hettinger wrote: Every class in the MRO implementing the target method *must* call super() to give the next class in the MRO a chance to run. EXCEPT for the last one, which must NOT call super! The posted

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Gregory Ewing
Steven D'Aprano wrote: A / \ C B \ / D / \ E F Yes, a super call might jog left from C to B, but only when being called from one of the lower classes D-F. That's still an upwards call relative to the originator, not sidewards. But it's not an upward

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Steven D'Aprano
On Sat, 31 Jul 2010 14:25:39 +1200, Gregory Ewing wrote: Steven D'Aprano wrote: A / \ C B \ / D / \ E F Yes, a super call might jog left from C to B, but only when being called from one of the lower classes D-F. That's still an upwards call

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Steven D'Aprano
On Fri, 30 Jul 2010 14:43:07 +0200, Jean-Michel Pichavant wrote: Quoting Michele's article (I think he's still hanging around this list) Readers familiar will single inheritance languages, such as Java or Smalltalk, will have a clear concept of superclass in mind. This concept, however, has

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-30 Thread Ian Kelly
On Fri, Jul 30, 2010 at 6:38 AM, Hrvoje Niksic hnik...@xemacs.org wrote: Gregory Ewing greg.ew...@canterbury.ac.nz writes: I think the point is that the name is misleading, because it makes it *sound* like it's going to call a method in a superclass, when it fact it might not. That is

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Sun, 25 Jul 2010 13:58:00 +1200, Gregory Ewing wrote: Lacrima wrote: But what if SuperClass1 is from third party library? If it hasn't been designed for super(), then you can't use super() with it. super() only works when *every* class in the

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 12:08:54 +0200, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: That incorrect. You can certainly use super() with classic classes in the hierarchy, and super() didn't even exist when they were created. The problem isn't super(), and people who give glib advise don't

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: [snip] super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. Come on Steven, you're better than this :) . Everybody can accurately guess what len and upper are

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 19:29:24 +0200, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: [snip] super() is just as explicit as len(), or str.upper(). It says, explicitly, that it will call the method belonging to one or more superclass of the given class. Come on Steven, you're better

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-26 Thread Ethan Furman
Gregory Ewing wrote: Raymond Hettinger wrote: Every class in the MRO implementing the target method *must* call super() to give the next class in the MRO a chance to run. EXCEPT for the last one, which must NOT call super! The posted example happens to work because object has a default

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-26 Thread Raymond Hettinger
[Ethan Furman] Speaking of new-style classes only, don't they all end in object?  And if the MRO is only known at run-time, how is one to know at code-time whether your (new-style) class is at the end of the line? That is a bit of a PITA. One way of handling it is to design your diamond so

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-25 Thread Raymond Hettinger
On Jul 24, 3:56 am, Lacrima lacrima.ma...@gmail.com wrote: Thank you for your answer. You're welcome. Some things are still not clear. Your example works great. But if I remove super(SuperClass1, self).__init__(**kwds) from SuperClass1's __init__, the example stops working. That is when I

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-25 Thread Gregory Ewing
Raymond Hettinger wrote: Every class in the MRO implementing the target method *must* call super() to give the next class in the MRO a chance to run. EXCEPT for the last one, which must NOT call super! The posted example happens to work because object has a default __init__ method that does

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-25 Thread Michele Simionato
Everything you ever wanted to know about super is collected here: http://micheles.googlecode.com/hg/artima/python/super.pdf M.S. -- http://mail.python.org/mailman/listinfo/python-list

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Raymond Hettinger
On Jul 24, 12:47 am, Lacrima lacrima.ma...@gmail.com wrote: Hi! I have two super classes: class SuperClass1(object):     def __init__(self, word):         print word class SuperClass2(object):     def __init__(self, word, word2):         print word, word2 Also I have subclass of these

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Lacrima
On Jul 24, 11:20 am, Raymond Hettinger raymond.hettin...@gmail.com wrote: On Jul 24, 12:47 am, Lacrima lacrima.ma...@gmail.com wrote: Hi! I have two super classes: class SuperClass1(object):     def __init__(self, word):         print word class SuperClass2(object):     def

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Gregory Ewing
Lacrima wrote: But what if SuperClass1 is from third party library? If it hasn't been designed for super(), then you can't use super() with it. super() only works when *every* class in the hierarchy has been designed with it in mind. -- Greg --

Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?

2010-07-24 Thread Steven D'Aprano
On Sun, 25 Jul 2010 13:58:00 +1200, Gregory Ewing wrote: Lacrima wrote: But what if SuperClass1 is from third party library? If it hasn't been designed for super(), then you can't use super() with it. super() only works when *every* class in the hierarchy has been designed with it in