<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000">> <span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">But the user could have had the false impression that additional kwargs</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> could be given when instantiating A. Obviously they are purely there for</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> getting the init in the MRO working with multiple inheritance.</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">This just isn't true. You often do things with the kargs before passing them</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">or other values to super. By using **kargs in the constructor and the call to</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">`super`, you are indicating that the signature passes through, but there are</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">many other things you could do instead.</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The docs *should* show that the derived method takes the same args as the</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">inherited one it overrides. That is very useful information that belongs there.</span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:#000000"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Best,</span></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace">-- Carl Smith</font></span><br></div></div><div><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace"><a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a></font></span></div></div></div></div></div></div>
<br><div class="gmail_quote">On 26 May 2018 at 01:06, Michael Lohmann <span dir="ltr"><<a href="mailto:mial.lohmann+pythonml@gmail.com" target="_blank">mial.lohmann+pythonml@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi!</div><div><br></div><div>***Disclaimer: I am relatively new to Python***<br></div><div><br></div><div>I propose to add some mechanism that can automatically collect everything what would normally be collected by **kwargs in the __init__ method and directly pass it through to the super().__init__ call without being accessible in the __init__ itself. This way the autocompletion/docstring generation could safely ignore this argument which before would have showed up as **kwargs.</div><div><br></div><div>I believe that this could greatly enhance the readability of automated documentation and especially the autocomplete of an IDE.</div><div><br></div><div>I would like something like this to work:</div><div><br></div><div>    class A:</div><div>        @pass_through_kwargs  # like this? Or maybe  __init__(self, a_value, ***pass_through_kwargs)?</div><div>        def __init__(self, a_value):</div><div>            super().__init__()  # <- realize that nothing is passed in here</div><div><br></div><div>    class B:</div><div>        def __init__(self, some_value):</div><div>            pass</div><div><br></div><div>    class MyClass(A, B):</div><div>        def __init__(self):</div><div>            super().__init__(a_value=1, some_value=2)</div><div><br></div><div>Where the autocomplete of `A(` shows me just `A(a_value)`. The pass_through_kwargs can safely be ignored, since it is not "a real input" of A. It is automatically merged with the parameters of the `super(A, self).__init__()` call. How exactly this should be done would have to be discussed in more detail (I guess the actual values should probably override the passed through ones).</div><div><br></div><div>With the current python version the code would have looked like</div><div><br></div><div>    class A:</div><div>        def __init__(self, a_value, **kwargs):</div><div>            super().__init__(**kwargs)</div><div><br></div><div>But the user could have had the false impression that additional kwargs could be given when instantiating A. Obviously they are purely there for getting the init in the MRO working with multiple inheritance.</div><div><br></div><div>One could also add something like pass_through_args as well but the usability of that is probably much more limited.</div><div><br></div><div>Could this even work in theory? I guess it might be quite tricky since `super().__init__` doesn't even have to be called. If that would be the case: should it be called automatically if pass_through_kwargs were given after the init is done?</div><div><br></div><div><br></div><div>By the way: Thank you all for this amazing language!</div><div>Cheers, Michael</div></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br></div>