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. -- http://mail.python.org/mailman/listinfo/python-l

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 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 B

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'Aprano 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 -- http://mail.python.org/mailman/li

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 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,

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 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 between Michel

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 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: java.lang.Runt

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

2010-08-01 Thread Paul Rubin
Michele Simionato 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: java.lang.RuntimeException: com.jives

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

2010-08-01 Thread Michele Simionato
On Jul 31, 5:08 am, Steven D'Aprano 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 idea that there is ONE > superclass

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 does

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

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 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 proper procedure for doing

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 wrote: > On Sat, Jul 31, 2010 at 4:22 AM, Steven D'Aprano > > > > 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 a

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 rather

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 Ian Kelly
On Sat, Jul 31, 2010 at 4:22 AM, Steven D'Aprano 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 super() documentation too c

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

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

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 wrote: > Gregory Ewing 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, especial

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

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 stil

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 ca

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 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 wor

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 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 notion that "superclass" me

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, whethe

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() o

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

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 pr

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 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-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, yo

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 d

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

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 hierarc

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-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 __init

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-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 no

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 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 instantiate > SubCla

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 > wi

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 -- http://mail.python.org/mailman/listinfo/python-

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

2010-07-24 Thread Lacrima
ns. > > 1) Inside __init__ of SubClass how can I firstly call __init__ of > > SuperClass1, and then __init__ of SuperClass2, using builtin super() > > function. > > I would write it like this: > > class SuperClass1(object): >     def __init__(self, **kwds): >  

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
; Also I have subclass of these classes: > > class SubClass(SuperClass1, SuperClass2): >     def __init__(self): >         pass > > I have two questions. > 1) Inside __init__ of SubClass how can I firstly call __init__ of > SuperClass1, and then __init__ of SuperClass2, using b

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

2010-07-24 Thread Lacrima
(self): pass I have two questions. 1) Inside __init__ of SubClass how can I firstly call __init__ of SuperClass1, and then __init__ of SuperClass2, using builtin super() function. 2) Why should I use super() at all, if it is very easy to call methods of super class like this: class SubClass

RE: Re: Super() function

2010-03-29 Thread Delaney, Timothy (Tim)
Gabriel Genellina write: > En Sun, 28 Mar 2010 21:58:07 -0300, Delaney, Timothy (Tim) > escribió: >>> Gabriel Genellina wrote: >>>> Alan Harris-Reid escribió: >>>> >>>>> Using Python 3.1, I sometimes use the super() function to call the &g

Re: Re: Super() function

2010-03-29 Thread Gabriel Genellina
En Sun, 28 Mar 2010 21:58:07 -0300, Delaney, Timothy (Tim) escribió: Gabriel Genellina wrote: Alan Harris-Reid escribió: Using Python 3.1, I sometimes use the super() function to call the equivalent method from a parent class, for example def mymethod(self): super().mymethod

RE: Re: Super() function

2010-03-28 Thread Delaney, Timothy (Tim)
> Gabriel Genellina wrote: >> Alan Harris-Reid escribió: >> >>> Using Python 3.1, I sometimes use the super() function to call the >>> equivalent method from a parent class, for example >>> >>> def mymethod(self): >>> super().myme

Re: Re: Super() function

2010-03-27 Thread Alan Harris-Reid
Gabriel Genellina wrote: En Thu, 25 Mar 2010 00:17:52 -0300, Alan Harris-Reid escribió: Using Python 3.1, I sometimes use the super() function to call the equivalent method from a parent class, for example def mymethod(self): super().mymethod() some more code... Is there any way

Re: Re: Super() function

2010-03-27 Thread Alan Harris-Reid
³p wrote: Hi: On 25 March 2010 11:17, Alan Harris-Reid <mailto:aharrisr...@googlemail.com>> wrote: Hi, Using Python 3.1, I sometimes use the super() function to call the equivalent method from a parent class, for example def mymethod(self): super()

Re: Super() function

2010-03-24 Thread Gabriel Genellina
En Thu, 25 Mar 2010 00:17:52 -0300, Alan Harris-Reid escribió: Using Python 3.1, I sometimes use the super() function to call the equivalent method from a parent class, for example def mymethod(self): super().mymethod() some more code... Is there any way of writing the code so

Re: Super() function

2010-03-24 Thread alex23
Alan Harris-Reid wrote: > Is there any way of writing the code so that the super() call is generic > and automatically recognises the name of the current method (ie. > something like super().thismethod()) or do I always have to repeat the > method name after super()? To the best of my knowledge,

Re: Super() function

2010-03-24 Thread 岳帅杰
Hi: On 25 March 2010 11:17, Alan Harris-Reid wrote: > Hi, > > Using Python 3.1, I sometimes use the super() function to call the > equivalent method from a parent class, for example > > def mymethod(self): > super().mymethod() > some more code... > > Is there

Super() function

2010-03-24 Thread Alan Harris-Reid
Hi, Using Python 3.1, I sometimes use the super() function to call the equivalent method from a parent class, for example def mymethod(self): super().mymethod() some more code... Is there any way of writing the code so that the super() call is generic and automatically recognises the