You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[py 3.5] Instantiating subclass throws exception: TypeError: no constructor matches given arguments #252
I have my own .NET library class that does not have a parameterless constructor. I want to subclass it in python and create a parameterless constructor. However, python always throws an error when I do not specify parameters on creating an instance of the class. The parameters for the C# class constructor is int, int.
Can you share minimum reproducible SadConsole.Consoles.Console?
There is an open pull request about overloading on constructor and also
subclassing a python class that inherits from .NET class is buggy (see
mailing list).
On Tuesday, August 30, 2016, Andy De George [email protected]
wrote:
I'm new to this
I'm using Python 3.5
I have my own .NET library class that does not have a parameterless
constructor. I want to subclass it in python and create a parameterless
constructor. However, python always throws an error when I do not specify
parameters on creating an instance of the class. The parameters for the C#
class constructor is int, int.
Is this a scenario we can cover some how? It seems that a .NET type as a base class, the .NET base class gets initialized before the Python inherited class, which is opposite to how it seems it should work.
So have you looked at using python closures? You would have your
alternative constructor logic in the outer function scope and use all .NET
methods in the inner scope.
On Wed, Aug 31, 2016 at 2:05 PM, Andy De George [email protected]
wrote:
Is this a scenario we can cover some how? It seems that a .NET type as a
base class, the .NET base class gets initialized before the Python
inherited class, which is opposite to how it seems it should work.
@Thraka you could just pass 2 dynamic objects (dyn_method and dyn_args) to constructor in C# not used on .NET side if null. Then just pass these dynamic object arguments to constructor on Python side to pass the python method and python arguments.
What's happen when the .Net constructor class returns a out string inside the parameters?
` public TestClass(string name, out string error)
{
error = "Error in the Initialization";
_name = name;
}`
How can I get the out string parameter from python in the instance of object? I've tried using tuples and have error TypeError: iteration over non-sequence
Activity
den-run-ai commentedon Aug 31, 2016
Can you share minimum reproducible
SadConsole.Consoles.Console?There is an open pull request about overloading on constructor and also
subclassing a python class that inherits from .NET class is buggy (see
mailing list).
On Tuesday, August 30, 2016, Andy De George [email protected]
wrote:
Thraka commentedon Aug 31, 2016
class-test.zip
Here you go. Very simple test with C# code provided.
den-run-ai commentedon Aug 31, 2016
This is error in both pythonnet and ironpython:
Thraka commentedon Aug 31, 2016
Is this a scenario we can cover some how? It seems that a .NET type as a base class, the .NET base class gets initialized before the Python inherited class, which is opposite to how it seems it should work.
den-run-ai commentedon Aug 31, 2016
Looking at history this limitation was originally like that in pythonnet.
And some updates on subclassing more recently here from @tonyroberts with
so many limitations listed:
http://code.activestate.com/lists/pythondotnet/1397/
So have you looked at using python closures? You would have your
alternative constructor logic in the outer function scope and use all .NET
methods in the inner scope.
On Wed, Aug 31, 2016 at 2:05 PM, Andy De George [email protected]
wrote:
den-run-ai commentedon Sep 20, 2016
@Thraka you could just pass 2 dynamic objects (dyn_method and dyn_args) to constructor in C# not used on .NET side if null. Then just pass these dynamic object arguments to constructor on Python side to pass the python method and python arguments.
den-run-ai commentedon Sep 20, 2016
filmor commentedon Jun 9, 2020
Since there have not been any updates in quite a while, I'll close this issue. Feel free to reopen and provide a information on the current state.
angel88c commentedon May 9, 2022
What's happen when the .Net constructor class returns a out string inside the parameters?
` public TestClass(string name, out string error)
{
error = "Error in the Initialization";
_name = name;
How can I get the out string parameter from python in the instance of object? I've tried using tuples and have error TypeError: iteration over non-sequence
error ='' obj, error = TestClass("Angel", '') print(obj)Thanks