Environment
Details
- Describe what you were trying to get done.
I am trying to use python child of .NET class in python grandchild.
class A:
def __init__(self):
self.foo()
def foo(self): print('A.foo')
class B(A):
def foo(self): print('B.foo')
a = A()
b = B()
works like expected and prints:
A.foo
B.foo
Consider Python classes constructed with pythonnet:
import clr
import System.Windows.Forms as WinForms
class PythonGroupBox(WinForms.GroupBox):
def __init__(self):
print("PythonGroupBox.__init__")
self.MyInit()
def MyInit(self):
print("PythonGroupBox MyInit")
class PythonGroupBoxDerived(PythonGroupBox):
def MyInit(self):
print("PythonGroupBoxDerived MyInit")
grp1 = PythonGroupBox()
grp2 = PythonGroupBoxDerived()
works fine and prints:
PythonGroupBox.init
PythonGroupBox MyInit
PPythonGroupBox.init
PythonGroupBoxDerived MyInit
Now the same with "namespace":
import clr
import System.Windows.Forms as WinForms
class PythonGroupBox(WinForms.GroupBox):
__namespace__ = "System.Windows.Forms"
def __init__(self):
print("PythonGroupBox.__init__")
self.MyInit()
def MyInit(self):
print("PythonGroupBox MyInit")
class PythonGroupBoxDerived(PythonGroupBox):
def MyInit(self):
print("PythonGroupBoxDerived MyInit")
grp1 = PythonGroupBox()
grp2 = PythonGroupBoxDerived()
The output is:
PythonGroupBox.init
PythonGroupBox MyInit
PythonGroupBox.init
PythonGroupBox MyInit
Error (1), because MyInit Method didn't get overloaded !!!
One more try:
import clr
import System.Windows.Forms as WinForms
class PythonGroupBox(WinForms.GroupBox):
__namespace__ = "System.Windows.Forms"
def __init__(self):
print("PythonGroupBox.__init__")
self.MyInit()
def MyInit(self):
print("PythonGroupBox MyInit")
class PythonGroupBoxDerived(PythonGroupBox):
__namespace__ = "System.Windows.Forms"
def MyInit(self):
print("PythonGroupBoxDerived MyInit")
grp1 = PythonGroupBox()
grp2 = PythonGroupBoxDerived()
Output gets really weird:
PythonGroupBox.init
PythonGroupBox MyInit
Error (2): during construction of PythonGroupBoxDerived the init() method was not called at all !!!
Important: this issue has nothing to do with issue #503: if I undo that fix than constructors get called twice, but errors described here persist.
Environment
Details
I am trying to use python child of .NET class in python grandchild.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Following pure python code
works like expected and prints:
Consider Python classes constructed with pythonnet:
works fine and prints:
Now the same with "namespace":
The output is:
Error (1), because MyInit Method didn't get overloaded !!!
One more try:
Output gets really weird:
Error (2): during construction of PythonGroupBoxDerived the init() method was not called at all !!!
Important: this issue has nothing to do with issue #503: if I undo that fix than constructors get called twice, but errors described here persist.