<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Oct 31, 2017 at 12:18 PM Koos Zevenhoven <<a href="mailto:k7hoven@gmail.com">k7hoven@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace"><span style="font-family:arial,sans-serif">On Tue, Oct 31, 2017 at 11:24 AM, Petr Viktorin </span><span dir="ltr" style="font-family:arial,sans-serif"><<a href="mailto:encukou@gmail.com" target="_blank">encukou@gmail.com</a>></span><span style="font-family:arial,sans-serif"> wrote:</span><br></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 10/31/2017 09:54 AM, Koos Zevenhoven wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_3139264614167226297gmail-">
<br>
I wonder if that's more easily understood if you write it along these line(s):<br>
<br>
(the_bob,) = (name for name in ('bob','fred') if name=='bob')<br>
</span></blockquote>
<br>
There are (unfortunately) several ways to do it. I prefer one that avoids a trailing comma:<br>
<br>
[the_bob] = (name for name in ('bob','fred') if name=='bob')<div class="m_3139264614167226297gmail-HOEnZb"><div class="m_3139264614167226297gmail-h5"><br></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"></blockquote><div><br></div><div class="gmail_default" style="font-family:monospace,monospace">Maybe it's just me, but somehow that list-like syntax as an assignment target feels wrong in somewhat the same way that (1, 2).append(3) does.</div></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div></div></blockquote><div><br></div><div>Off topic: why can't we simply allow something like this:</div><div><br></div><div> (the_bob) = (name for name in ('bob','fred') if name=='bob')</div><div><br></div><div>Why does Python treat the parenthesis at the LHS as grouping parens? operators are not allowed anyway; (a + (b + c)) = [1] is syntax error.</div><div><br></div><div>Currently </div><div><br></div><div> (x) = 1</div><div><br></div><div>works, but I can't see why should it.</div><div><br></div><div>Elazar</div></div></div>