Message384290
> 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. |
|
Date |
User |
Action |
Args |
2021-01-03 17:55:40 | uriyyo | set | recipients:
+ uriyyo, chaim422 |
2021-01-03 17:55:40 | uriyyo | set | messageid: <1609696540.65.0.855863567187.issue42812@roundup.psfhosted.org> |
2021-01-03 17:55:40 | uriyyo | link | issue42812 messages |
2021-01-03 17:55:40 | uriyyo | create | |
|