Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deriving from .NET types in Python does not inherit constructor #1945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lostmsu opened this issue Sep 17, 2022 · 0 comments
Open

Deriving from .NET types in Python does not inherit constructor #1945

lostmsu opened this issue Sep 17, 2022 · 0 comments

Comments

@lostmsu
Copy link
Member

lostmsu commented Sep 17, 2022

from System import Object

class L1(Object):
  __namespace__ = 'TestNS'
  def __init__(self):
    super().__init__()
    print('42')

class L2(L1):
  __namespace__ = 'TestNS'

o = L2() # 42 is not printed

Workaround

Explicitly redefine __init__ in L2:

class L3(L1):
  __namespace__ = 'TestNS'
  def __init__(self):
    super().__init__()

o = L3() # prints '42'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant