"Incorrect" behavior of inheriting from class which is inherited from .Net class

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

Hi, yes, deriving from a python class in Python that itself is derived from a .net class doesn't work. Apologies, if I'd known that was what you were doing I could have saved you some time by telling you that earlier. AFAIK this hasn't been created as an issue in github, so please if you could do that that would be helpful. It's probably not that hard to make work, but it's not something I've got time to look at myself right now I'm afraid. If anyone else wants to have a go and needs pointing in the right direction let me know. Tony On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny@live.com> wrote:
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, System class 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 output string BaseNA.baseNA BaseNB.baseNB BaseNB.baseNB BaseNB.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 - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet

*Hi Hansong, * I noticed that you (@hhspiny) released your WPF adventures with pythonnet on github, but without a license: https://github.com/hhspiny/WPFPy Can you please indicate the license? *Hi Tony,* Please let me know how this subclassing (.NET -> Python -> Python) would work? *Thanks,* *Denis* On Mon, Apr 11, 2016 at 2:04 AM, Tony Roberts <tony@pyxll.com> wrote:
Hi,
yes, deriving from a python class in Python that itself is derived from a .net class doesn't work. Apologies, if I'd known that was what you were doing I could have saved you some time by telling you that earlier.
AFAIK this hasn't been created as an issue in github, so please if you could do that that would be helpful. It's probably not that hard to make work, but it's not something I've got time to look at myself right now I'm afraid. If anyone else wants to have a go and needs pointing in the right direction let me know.
Tony On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny@live.com> wrote:
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, System class 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 output string BaseNA.baseNA BaseNB.baseNB BaseNB.baseNB BaseNB.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 - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet

Hi Denis, There is no licenses term. I simply used github to save files to work on between home and work. it is free to use by anyone. Since the current pythonnet does not really allow derive from class derived from .NET class. I can't really do what I intended to do, and therefore, I have not spent time on it further. I don't know much about the internal of python to contribute to correct the problem. The framework currently in github does work fine using ExpandoObject class directly. so it would be ok to be used for simpler program. Regards, Hansong ________________________________ From: Denis Akhiyarov <denis.akhiyarov@gmail.com> Sent: Thursday, August 25, 2016 11:15:37 AM To: A list for users and developers of Python for .NET Cc: hhspiny@pine.cc Subject: Re: [Python.NET] "Incorrect" behavior of inheriting from class which is inherited from .Net class Hi Hansong, I noticed that you (@hhspiny) released your WPF adventures with pythonnet on github, but without a license: https://github.com/hhspiny/WPFPy Can you please indicate the license? Hi Tony, Please let me know how this subclassing (.NET -> Python -> Python) would work? Thanks, Denis On Mon, Apr 11, 2016 at 2:04 AM, Tony Roberts <tony@pyxll.com<mailto:tony@pyxll.com>> wrote: Hi, yes, deriving from a python class in Python that itself is derived from a .net class doesn't work. Apologies, if I'd known that was what you were doing I could have saved you some time by telling you that earlier. AFAIK this hasn't been created as an issue in github, so please if you could do that that would be helpful. It's probably not that hard to make work, but it's not something I've got time to look at myself right now I'm afraid. If anyone else wants to have a go and needs pointing in the right direction let me know. Tony On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny@live.com<mailto:hhspiny@live.com>> wrote: 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, System class 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 output string BaseNA.baseNA BaseNB.baseNB BaseNB.baseNB BaseNB.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<http://python.net> or was intended. regards, Hansong _________________________________________________ Python.NET mailing list - PythonDotNet@python.org<mailto:PythonDotNet@python.org> https://mail.python.org/mailman/listinfo/pythondotnet _________________________________________________ Python.NET mailing list - PythonDotNet@python.org<mailto:PythonDotNet@python.org> https://mail.python.org/mailman/listinfo/pythondotnet

Ok, do you agree to MIT license for your code? I may use some of your code to contribute to WPF demo. https://github.com/pythonnet/pythonnet/pull/185 On Thu, Aug 25, 2016 at 10:44 AM, Hansong Huang <hhspiny@pine.cc> wrote:
Hi Denis,
There is no licenses term. I simply used github to save files to work on between home and work. it is free to use by anyone.
Since the current pythonnet does not really allow derive from class derived from .NET class. I can't really do what I intended to do, and therefore, I have not spent time on it further. I don't know much about the internal of python to contribute to correct the problem.
The framework currently in github does work fine using ExpandoObject class directly. so it would be ok to be used for simpler program.
Regards,
Hansong ------------------------------ *From:* Denis Akhiyarov <denis.akhiyarov@gmail.com> *Sent:* Thursday, August 25, 2016 11:15:37 AM *To:* A list for users and developers of Python for .NET *Cc:* hhspiny@pine.cc *Subject:* Re: [Python.NET] "Incorrect" behavior of inheriting from class which is inherited from .Net class
*Hi Hansong, *
I noticed that you (@hhspiny) released your WPF adventures with pythonnet on github, but without a license:
https://github.com/hhspiny/WPFPy
Can you please indicate the license?
*Hi Tony,*
Please let me know how this subclassing (.NET -> Python -> Python) would work?
*Thanks,* *Denis*
On Mon, Apr 11, 2016 at 2:04 AM, Tony Roberts <tony@pyxll.com> wrote:
Hi,
yes, deriving from a python class in Python that itself is derived from a .net class doesn't work. Apologies, if I'd known that was what you were doing I could have saved you some time by telling you that earlier.
AFAIK this hasn't been created as an issue in github, so please if you could do that that would be helpful. It's probably not that hard to make work, but it's not something I've got time to look at myself right now I'm afraid. If anyone else wants to have a go and needs pointing in the right direction let me know.
Tony On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny@live.com> wrote:
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, System class 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 output string BaseNA.baseNA BaseNB.baseNB BaseNB.baseNB BaseNB.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 - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet
participants (4)
-
Denis Akhiyarov
-
Hansong Huang
-
Hansong Huang
-
Tony Roberts