Yurii Karabas <[email protected]> added the comment:
> What is better?
Sorry, I can't answer this question.
I am a regular python user and I just tried to help with your issue.
I believe we should wait for someone from core team to answer this question.
> In your example, does Child foo call Parent foo? Because the intent is to use
> the parent's foo method.
Sorry, I made a mistake, it definitely should call a parent method. A correct
example will look like this:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""
class Child(Parent):
def foo(self, a, b):
super().foo(a=a, b=b)
```
But, the example above require more code to write, so a better option will be:
```
class Parent:
def foo(self, **kwargs):
"""Argument names of foo vary depending on the child class."""
class Child(Parent):
@overload
def foo(self, a, b):
pass
@overload
def foo(self, **kwargs):
pass
def foo(self, **kwargs):
return super().foo(**kwargs)
```
I am not sure is it the perfect solution to solve your issue.
Let's wait for someone from core team, so we can hear their opinion.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42812>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com