On 27/05/2019 04:52:17, Montana Burr wrote: > NumPy arrays have this awesome feature, where array == 3 does an > element-wise comparison and returns a list. For example: > > np.array([1,2,3,4,5])==3 > > returns > > [False,False,True,False,False] > > It would be cool if Python had similar functionality for lists. > Well, it does have: >>> [x==3 for x in [1,2,3,4,5]] [False, False, True, False, False] This is IMHO much more intuitive than your construct overloading "==". It is also more flexible (any operation can be performed on x, not just an equality comparison). So sorry, but I can see no justification for changing the Python language to do something, which can already be done, to be done in a more obscure way. Also [1,2,3,4,5]==3 is already legal syntax (it evaluates to False, since the operands are not equal), so you are proposing a code-breaking change. Apologies if someone has already pointed all this out, as is very likely (I have only just (re-)joined python-ideas and may have missed the relevant posts). Best wishes Rob Cliffe
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4