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/2008-July/081061.html below:

[Python-Dev] Proposed unittest changes

[Python-Dev] Proposed unittest changes [Python-Dev] Proposed unittest changesTim Peters tim.peters at gmail.com
Mon Jul 14 02:32:12 CEST 2008
[Michael Foord]
>> ...
>> Adding the following new asserts:
>>
>> ...
>>   assertNotIs   (first, second, msg=None)

[Steve Holden]
> Please, let's call this one "assertIsNot".

+1

> I know it's valid Python to say
>
>  if a not is b:

Nope, that's a syntax error.

> but it's a much less natural way of expressing the condition, and (for all I
> know) might even introduce an extra negation operation. "is not" is, I
> believe, treated as a single operator.

"is not" and "not in" are both binary infix operators, not to be
confused with the distinct use of "not" on its own as a unary prefix
operator.  "not is" and "in not" are both gibberish.

>>> 1 is not 2
True
>>> 1 is (not 2)
False
>>> 1 not is 2
SyntaxError: invalid syntax

>>> 1 not in [2]
True
>>> 1 in not [2]
SyntaxError: invalid syntax
>>> 1 in (not [2])
Traceback (most recent call last):
   ...
TypeError: argument of type 'bool' is not iterable
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