<div dir="ltr">Ok, now I'm mildly curious to knpw:<div><br></div><div>What is the justification for causing list == 3 to evaluate to False, besides the obvious "a list cannot equal a number"?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 28, 2019 at 9:34 PM Montana Burr <<a href="mailto:montana.burr@gmail.com">montana.burr@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Ok, now I'm mildly curious to knpw:<div><br></div><div>What is the justification for causing list == 3 to evaluate to False, besides the obvious "a list cannot equal a number"?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 28, 2019 at 7:52 PM Rob Cliffe <<a href="mailto:rob.cliffe@btinternet.com" target="_blank">rob.cliffe@btinternet.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 27/05/2019 04:52:17, Montana Burr wrote:<br>
> NumPy arrays have this awesome feature, where array == 3 does an <br>
> element-wise comparison and returns a list. For example:<br>
><br>
> np.array([1,2,3,4,5])==3<br>
><br>
> returns<br>
><br>
> [False,False,True,False,False]<br>
><br>
> It would be cool if Python had similar functionality for lists.<br>
><br>
Well, it does have:<br>
 >>>  [x==3 for x in [1,2,3,4,5]]<br>
[False, False, True, False, False]<br>
<br>
This is IMHO much more intuitive than your construct overloading "==".<br>
It is also more flexible (any operation can be performed on x, not just <br>
an equality comparison).<br>
So sorry, but I can see no justification for changing the Python <br>
language to do something, which can already be done, to be done in a <br>
more obscure way.<br>
Also<br>
     [1,2,3,4,5]==3<br>
is already legal syntax (it evaluates to False, since the operands are <br>
not equal), so you are proposing a code-breaking change.<br>
<br>
Apologies if someone has already pointed all this out, as is very likely <br>
(I have only just (re-)joined python-ideas and may have missed the <br>
relevant posts).<br>
Best wishes<br>
Rob Cliffe<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_2117074262132671768gmail_signature"><br><div><div><div>WebRep</div></div><img><div>Overall rating</div><img><div></div><div></div><div><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"></div><div><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"></div><img><div> </div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><br><div><div><div>WebRep</div></div><img><div>Overall rating</div><img><div></div><div></div><div><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"></div><div><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"><img width="30" height="30"></div><img><div> </div></div></div>