Re: [Tutor] Basic class inheritance

2005-07-28 Thread Kent Johnson
Alan G wrote: >>> Now I want that another class, call it B, inherits all >>> behaviours/attributes except for the attribute blank, that now I want >>> to be False. > > >> class B(A): >> def __init__(self, blank=True, editable=True, name='foo'): >>A.__init__(self, blank, editable, name) > >

Re: [Tutor] Basic class inheritance

2005-07-28 Thread Alan G
>> Now I want that another class, call it B, inherits all >> behaviours/attributes except for the attribute blank, that now I >> want >> to be False. > class B(A): > def __init__(self, blank=True, editable=True, name='foo'): >A.__init__(self, blank, editable, name) except that instead of pa

Re: [Tutor] Basic class inheritance

2005-07-28 Thread Negroup -
[cut] > > Yes, that is the more modern way to do it for new-style classes. In the > original example, class A does not inherit from object so I used the older > style. > Thanks guys for your answers, it's clear (even if I wouldn't be able to figure it out by my own). About old style/new style

Re: [Tutor] Basic class inheritance

2005-07-28 Thread Kent Johnson
Cedric BRINER wrote: >>>However, is it possible to achieve this without rewrite the whole >>>__init__ method, but just overriding parts of it? >> >>The usual way to do this is to forward to the __init__() method of the >>superclass for the common part. In your case you are just specializing the >

Re: [Tutor] Basic class inheritance

2005-07-28 Thread Cedric BRINER
> > However, is it possible to achieve this without rewrite the whole > > __init__ method, but just overriding parts of it? > > The usual way to do this is to forward to the __init__() method of the > superclass for the common part. In your case you are just specializing the > default arguments

Re: [Tutor] Basic class inheritance

2005-07-28 Thread Kent Johnson
Negroup - wrote: > I have this class: > class A: > > ... def __init__(self, blank=False, editable=True, name='foo'): > ... self.blank = blank > ... self.editable = editable > ... self.name = name > ... > a = A() a.blank, a.editable, a.name > >

[Tutor] Basic class inheritance

2005-07-28 Thread Negroup -
I have this class: >>> class A: ... def __init__(self, blank=False, editable=True, name='foo'): ... self.blank = blank ... self.editable = editable ... self.name = name ... >>> a = A() >>> a.blank, a.editable, a.name (False, True, 'foo') All as expected. No