newb __init__ inheritance

Colin J. Williams cjw at ncf.ca
Sat Mar 10 17:47:41 EST 2012


On 10/03/2012 12:58 PM, Colin J. Williams wrote:
> On 08/03/2012 10:25 AM, hyperboogie wrote:
>> Hello everyone.
>>[snip]
> main()
> I'm not sure that the class initialization is required.
>> Good luck,
>> Colin W.
When I wrote earlier, I wondered about the need for initialization.
With Version 2, both __new__ and __init__ were required, not in the 
example below, using version 3.2:
#!/usr/bin/env python
class A():
 def ringA(self):
 print ('aaa')
 def ringB(self):
 print('bbb')
class B(A):
 def __init__(self:)
 def ringB(self):
 print('BBB')
a= A()
b= B()
b.ringB()
b.ringA()
b.__class__.mro()[0].ringB(22) # 22 is used for the ringB attribute
 # Trial and error shows that any
 # non-Null,including None for the
 # argument gives the same result
z= 1
def main():
 pass
if __name__ == '__main__':
 main()
Colin W.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /