<br><br>On Saturday, January 26, 2019, Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Perhaps you should start by telling us *precisely* what the problem is <br>
that your subclass will solve. Because I don't know what your idea of <br>
dict unpacking is, and how it compares or differs from previous times it <br>
has been proposed.</blockquote><div><br></div><div>Dataclasses initialization may be most useful currently implemented syntactic sugar for a dict return value contract that specifies a variable name (and datatype)?</div><div><br></div><div>Is there a better way to specify a return object interface with type annotations that throws exceptions at runtime that dataclasses?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Are there any other languages which support dict unpacking? How does it <br>
work there?</blockquote><div><br></div><div>This about object destructuring in JS is worth a read:</div><div><br></div><div><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring</a><br></div><div><br></div><div>Here are two simple cases:</div><div><br></div><div>"""</div><div><div>var o = {p: 42, q: true};</div><div>var {p: foo, q: bar} = o;</div><div> </div><div>console.log(foo); // 42 </div><div>console.log(bar); // true</div></div><div>"""</div><div><br></div><div>Does it throw an exception when a value is undefined?</div><div>You can specify defaults:</div><div><br></div><div>"""</div><div><div>var {a: aa = 10, b: bb = 5} = {a: 3};</div><div><br></div><div>console.log(aa); // 3</div><div>console.log(bb); // 5</div></div><div>"""</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
-- <br>
Steve<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" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</blockquote>