On Mon, Oct 4, 2021 at 1:09 AM <[email protected]> wrote: > Thank you for pointing this out. This is the code block which includes the > first appearance of the keyword `logical_not`. > > BTW, why can't the ~ operator be tested equal to 'np.invert', as shown > below: > > ``` > In [1]: import numpy as np > In [3]: np.invert is np.bitwise_not > Out[3]: True > > In [4]: np.invert is ~ > File "<ipython-input-4-32abf1603b17>", line 1 > np.invert is ~ > ^ > SyntaxError: invalid syntax > ``` >
That’s just the way Python’s syntax works. Operators are not names that can be resolved to objects that can be compared with the `is` operator. Instead, when that operator is evaluated in an expression, the Python interpreter will look up a specially-named method on the operand object (in this case `__invert__`). Numpy array objects implement this method using `np.invert`. -- Robert Kern
_______________________________________________ NumPy-Discussion mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: [email protected]
