Skip to content

[py 3.5] Instantiating subclass throws exception: TypeError: no constructor matches given arguments #252

@Thraka

Description

@Thraka

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.

sub class

class TestConsole(SadConsole.Consoles.Console):

    def __init__(self):
        super().__init__(80, 25)
        super().Print(0, 0, "right constructor")

    def __init__(self, x, y):
        super().__init__(x, y)
        super().Print(0, 0, "wrong constructor")

calling code that crashes with error

new_console = TestConsole()

force parameters, it works fine, but obviously prints out "wrong constructor"

new_console = TestConsole(80, 25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions