<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Jul 28, 2017 at 12:51 AM Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Jul 28, 2017 at 7:22 AM, Pavol Lisy <<a href="mailto:pavol.lisy@gmail.com" target="_blank">pavol.lisy@gmail.com</a>> wrote:<br><br>
> We have:<br>
> from module import x, y, z  # where order is not important<br>
><br>
> Could we have something similar with ntuple (SimpleNamespace, ...)?<br>
><br>
> maybe:<br>
> for x, y, z from spam:<br>
>     print(x, y, z)<br>
<br>
What you're asking for is something like JavaScript's "object<br>
destructuring" syntax. It would sometimes be cool, but I haven't ever<br>
really yearned for it in Python. But you'd need to decide whether you<br>
want attributes (spam.x, spam.y) or items (spam["x"], spam["y"]). Both<br>
would be useful at different times.<br>
<br></blockquote><div><div><br class="inbox-inbox-Apple-interchange-newline">Maybe something like</div><div><br></div><div>    {x, y} = point</div><div><br></div><div>Or with aliasing</div><div><br></div><div>    {x as dx, y as dy} = point</div><div><br></div><div>Then you can have</div><div><br></div><div>    {'x' as x, 'y' as y, **} = spam</div><div> </div><div><br></div><div>Elazar</div></div><div><br></div></div></div>