A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-April/111094.html below:

[Python-Dev] PyObject_RichCompareBool identity shortcut

[Python-Dev] PyObject_RichCompareBool identity shortcut [Python-Dev] PyObject_RichCompareBool identity shortcutGreg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 29 03:08:05 CEST 2011
Nick Coghlan wrote:

> I hadn't really thought about it that way before this discussion - it
> is the identity checking behaviour of the builtin containers that lets
> us sensibly handle cases like sets of NumPy arrays.

Except that it doesn't:

 >>> from numpy import array
 >>> a1 = array([1,2])
 >>> a2 = array([3,4])
 >>> s = set([a1, a2])
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'numpy.ndarray'

Lists aren't trouble-free either:

 >>> lst = [a1, a2]
 >>> a2 in lst
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. 
Use a.any() or a.all()

-- 
Greg
More information about the Python-Dev mailing list

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