[Python.NET] "Incorrect" behavior of inheriting from class which is inherited from .Net class
Hansong Huang <[email protected]>
| Newsgroups | gmane.comp.python.dotnet |
|---|---|
| Message-ID | <[email protected]> |
Hello, This is related to previous investigation of inheriting from .NET interface class to create WPF MVVM structure. As now I believe it has nothing to do with interface class, but instead caused by inheriting from .Net class overall. please see the following code import clr, Systemclass baseNA(System.Random): __namespace__ = "BaseNA" def __init__(self): super(baseNA,self).__init__()# @clr.clrmethod(System.String,[]) def ToString(self): return "string" class baseNB(baseNA): __namespace__ = "BaseNB" def __init__(self): super(baseNB,self).__init__()bna = baseNA()print bna.ToString()print bna._Random__ToString()bnb = baseNB()print bnb.ToString()print bnb._baseNA__ToString()print bnb._Random__ToString() This produces the following outputstringBaseNA.baseNABaseNB.baseNBBaseNB.baseNBBaseNB.baseNB as you see, while baseNA -- the first level inherited class works fine. ToString() overrides System.Random.ToString() But baseNB inherited from baseNA did not inherit ToString() method from baseNA, but rather inherited from System.Random. Not sure if it is a bug in python.net or was intended. regards, Hansong _________________________________________________ Python.NET mailing list - [email protected] https://mail.python.org/mailman/listinfo/pythondotnet