On Saturday, January 26, 2019, Steven D'Aprano <steve@pearwood.info> wrote:
Perhaps you should start by telling us *precisely* what the problem is
that your subclass will solve. Because I don't know what your idea of
dict unpacking is, and how it compares or differs from previous times it
has been proposed.
Dataclasses initialization may be most useful currently implemented syntactic sugar for a dict return value contract that specifies a variable name (and datatype)?
Is there a better way to specify a return object interface with type annotations that throws exceptions at runtime that dataclasses?
Are there any other languages which support dict unpacking? How does it
work there?
This about object destructuring in JS is worth a read:
Here are two simple cases:
"""
var o = {p: 42, q: true};
var {p: foo, q: bar} = o;
console.log(foo); // 42
console.log(bar); // true
"""
Does it throw an exception when a value is undefined?
You can specify defaults:
"""
var {a: aa = 10, b: bb = 5} = {a: 3};
console.log(aa); // 3
console.log(bb); // 5
"""
--
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/