
On Fri, Jul 28, 2017 at 12:51 AM Chris Angelico <rosuav@gmail.com> wrote:
On Fri, Jul 28, 2017 at 7:22 AM, Pavol Lisy <pavol.lisy@gmail.com> wrote:
We have: from module import x, y, z # where order is not important
Could we have something similar with ntuple (SimpleNamespace, ...)?
maybe: for x, y, z from spam: print(x, y, z)
What you're asking for is something like JavaScript's "object destructuring" syntax. It would sometimes be cool, but I haven't ever really yearned for it in Python. But you'd need to decide whether you want attributes (spam.x, spam.y) or items (spam["x"], spam["y"]). Both would be useful at different times.
Maybe something like {x, y} = point Or with aliasing {x as dx, y as dy} = point Then you can have {'x' as x, 'y' as y, **} = spam Elazar