Re: [Tutor] Overriding a method in a class

2011-05-15 Thread Terry Carroll
On Sat, 14 May 2011, Alan Gauld wrote: Is there any reason you can'tt override in the uisual way by inheritance? Doh! Of course I should. I've written plenty of classes before, but never one intended to be inherited, and now that you point it out, it's obvious that that's what I should be

Re: [Tutor] Overriding a method in a class

2011-05-14 Thread Alan Gauld
"Terry Carroll" wrote in message I have a pretty basic point of confusion that I'm hoping I can have explained to me. I have a class in which I want to override a method, and have my method defined externally to the class definition invoked instead. Is there any reason you can'tt override

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Peter Otten
Terry Carroll wrote: > I have a pretty basic point of confusion that I'm hoping I can have > explained to me. I have a class in which I want to override a method, and > have my method defined externally to the class definition invoked instead. > But when I do so, my external method is invoked wit

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
On Fri, 13 May 2011, Terry Carroll wrote: For my specific case, I'm going to go with a Plan B of using callbacks; and provide default unbound callbacks present in the module, but not defined in the class itself. Here's a callback-with-default approach, which works: ### Thing.py

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
On Fri, 13 May 2011, David Knupp wrote: I think the problem is this bit about overriding an object's internal method with one that is defined externally. Yes, that describes the phenomenon. My gut feeilng is that you'd now have to explicitly pass the object (i.e., self) as well as the strin

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread David Knupp
I think the problem is this bit about overriding an object's internal method with one that is defined externally. My gut feeilng is that you'd now have to explicitly pass the object (i.e., self) as well as the string, i.e.: B.addstuff(B, "WXYZ") ...which seems clunky. I'm not familiar with t

Re: [Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
On Fri, 13 May 2011, Terry Carroll wrote: What I *expect* is to see ['abcdefg'] printed. What I get is: Sorry, mixed multiple examples; What I had expected was ['wxyz']. Still the same question though. BTW, I forgot to mention: Python 2.7.1, under Windows. (Still not used to the Python

[Tutor] Overriding a method in a class

2011-05-13 Thread Terry Carroll
I have a pretty basic point of confusion that I'm hoping I can have explained to me. I have a class in which I want to override a method, and have my method defined externally to the class definition invoked instead. But when I do so, my external method is invoked with a different argument sig