[Python.NET] "Incorrect" behavior of inheriting from class which is inherited from .Net class
denis.akhiyarov at gmail.com
Thu Aug 25 11:15:37 EDT 2016
*Hi Hansong, *
I noticed that you (@hhspiny) released your WPF adventures with pythonnet
on github, but without a license:
Can you please indicate the license?
Please let me know how this subclassing (.NET -> Python -> Python) would
On Mon, Apr 11, 2016 at 2:04 AM, Tony Roberts <tony at pyxll.com> wrote:
> 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.
> On Mon, Apr 11, 2016 at 3:41 AM Hansong Huang <hhspiny at live.com> wrote:
>> 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):
>> # @clr.clrmethod(System.String,)
>> def ToString(self):
>> return "string"
>> class baseNB(baseNA):
>> __namespace__ = "BaseNB"
>> def __init__(self):
>> 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
>> 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.
>> Python.NET mailing list - PythonDotNet at python.org
> Python.NET mailing list - PythonDotNet at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PythonDotNet