Re: [Tutor] Modify inherited methods

2010-04-28 Thread Eike Welk
On Wednesday April 28 2010 20:57:27 C M Caine wrote: > Thank you all. One tangentially related question: what does (self, > *args, **kwargs) actually mean? How does one reference variables given > to a function that accepts these inputs? *args is a tuple containing the positional arguments; **kwa

Re: [Tutor] Modify inherited methods

2010-04-28 Thread C M Caine
Thank you all. One tangentially related question: what does (self, *args, **kwargs) actually mean? How does one reference variables given to a function that accepts these inputs? Colin ___ Tutor maillist - Tutor@python.org To unsubscribe or change subs

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Eike Welk
On Wednesday April 28 2010 13:04:30 Steven D'Aprano wrote: > On Wed, 28 Apr 2010 04:53:06 pm Walter Wefft wrote: > > Steven D'Aprano wrote: > > > And for guru-level mastery, replace to call to dict.__init__ with > > > ... > > > > nothing at all, because dict.__init__ doesn't do anything. > > [..

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Emile van Sebille
On 4/28/2010 9:32 AM Walter Wefft said... Emile van Sebille wrote: On 4/28/2010 3:20 AM Walter Wefft said... You reiterate my point. To say that dict.__init__ can be omitted in a subclass's __init__ with no effect, is not a correct statement. It wasn't the omitted case that exhibits the diff

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Walter Wefft
Emile van Sebille wrote: On 4/28/2010 3:20 AM Walter Wefft said... spir ☣ wrote: On Wed, 28 Apr 2010 07:53:06 +0100 Walter Wefft wrote: === class MyDict0(dict): pass class MyDict1(dict): def __init__(self, *args, **kw): pass class MyDict2(dict): def __init__(self

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Emile van Sebille
On 4/28/2010 3:20 AM Walter Wefft said... spir ☣ wrote: On Wed, 28 Apr 2010 07:53:06 +0100 Walter Wefft wrote: === class MyDict0(dict): pass class MyDict1(dict): def __init__(self, *args, **kw): pass class MyDict2(dict): def __init__(self, *args, **kw): dict.__ini

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Steven D'Aprano
On Wed, 28 Apr 2010 04:53:06 pm Walter Wefft wrote: > Steven D'Aprano wrote: > > And for guru-level mastery, replace to call to dict.__init__ with > > ... > > nothing at all, because dict.__init__ doesn't do anything. [...] > Behaviour is different depending on whether you call the superclass > _

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Walter Wefft
spir ☣ wrote: On Wed, 28 Apr 2010 07:53:06 +0100 Walter Wefft wrote: Steven D'Aprano wrote: > And for guru-level mastery, replace to call to dict.__init__ with ... nothing at all, because dict.__init__ doesn't do anything. > > > (Sorry, should have sent to list). I don't understand thi

Re: [Tutor] Modify inherited methods

2010-04-28 Thread spir ☣
On Wed, 28 Apr 2010 07:53:06 +0100 Walter Wefft wrote: > Steven D'Aprano wrote: > > And for guru-level mastery, replace to call to dict.__init__ with ... > nothing at all, because dict.__init__ doesn't do anything. > > > > > > > > (Sorry, should have sent to list). > > I don't understand t

Re: [Tutor] Modify inherited methods

2010-04-28 Thread Walter Wefft
Steven D'Aprano wrote: > And for guru-level mastery, replace to call to dict.__init__ with ... nothing at all, because dict.__init__ doesn't do anything. > > > (Sorry, should have sent to list). I don't understand this - it must do something: class MyDict1(dict): def __init__(self, *args,

Re: [Tutor] Modify inherited methods

2010-04-27 Thread Alan Gauld
"Steven D'Aprano" wrote On Wed, 28 Apr 2010 07:24:48 am C M Caine wrote: I'm writing a class that inherits the inbuilt dict class and want some of my own code to run at initialisation, on the other hand, I still want the original dict.__init__ function to run. ... This is the general techni

Re: [Tutor] Modify inherited methods

2010-04-27 Thread Steven D'Aprano
On Wed, 28 Apr 2010 08:08:12 am Steven D'Aprano wrote: > Some people argue that you must call dict.__init__ even though it > doesn't do anything. Their reasoning is, some day its behaviour might > change, and if you don't call it in your subclass, then your class > may break. This is true, as far

Re: [Tutor] Modify inherited methods

2010-04-27 Thread Steven D'Aprano
On Wed, 28 Apr 2010 07:24:48 am C M Caine wrote: > I'm writing a class that inherits the inbuilt dict class and want > some of my own code to run at initialisation, on the other hand, I > still want the original dict.__init__ function to run. Can I ask the > class to run the original __init__ and t

[Tutor] Modify inherited methods

2010-04-27 Thread C M Caine
I'm writing a class that inherits the inbuilt dict class and want some of my own code to run at initialisation, on the other hand, I still want the original dict.__init__ function to run. Can I ask the class to run the original __init__ and then my own function at initialisation automatically? If s