May-08-2018, 02:22 PM
I am trying to create below hierarchy in my python code. But I am facing some issue when I am inheriting telnet library. This issue is coming in python 3.6.
Can somebody please guide me here, What I am doing wrong. I am really stuck here.
The same code works perfectly fine with python 2.7.
Thanks in advance!
Regards, Sourabh Jaiswal
import telnetlib class A(telnetlib.Telnet): def __init__(self): print("init A") super(A, self).__init__() class B(object): def __init__(self): print("init B") super(B, self).__init__() class C(B): def __init__(self): print("init C") super(C, self).__init__() class D(object): def __init__(self): print("init D") super(D, self).__init__() class E(C,D): def __init__(self): print("init E") super(E, self).__init__() class F(A,E): def __init__(self): print("init F") super(F, self).__init__() if __name__ == '__main__': F()Output in python3.6:-
Output:init F
init A
Output in python2.7:-Output:init F
init A
init E
init C
init B
init D
Exception AttributeError: "'F' object has no attribute 'sock'" in <bound method F.__del__ of <__main__.F object at 0x7f6a9f36a6d0>> ignored
Output in python3.6 without telnet library:-Output:init F
init A
init E
init C
init B
init D
if I run the same code and derive class 'A' from object instead of telnetlib.Telnet the constructor calling works fine.Can somebody please guide me here, What I am doing wrong. I am really stuck here.
The same code works perfectly fine with python 2.7.
Thanks in advance!
Regards, Sourabh Jaiswal