<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Truth_Value_Testing</id>
	<title>Truth Value Testing - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Truth_Value_Testing"/>
	<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Truth_Value_Testing&amp;action=history"/>
	<updated>2026-06-19T01:15:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=Truth_Value_Testing&amp;diff=136&amp;oldid=prev</id>
		<title>Davrot: Created page with &quot;Questions to [mailto:davrot@uni-bremen.de David Rotermund]  [https://docs.python.org/3/library/stdtypes.html#truth-value-testing “Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.”]  = Common mistake to avoid = For True, False, None we use is and is not for comparisons. They are objects and not values thus we need to use is and is not.  Correct&lt;syntaxhighlight lang=&quot;python&quot;&gt;if a: # &quot;a is True&quot;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Truth_Value_Testing&amp;diff=136&amp;oldid=prev"/>
		<updated>2025-10-15T10:52:12Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Questions to [mailto:davrot@uni-bremen.de David Rotermund]  [https://docs.python.org/3/library/stdtypes.html#truth-value-testing “Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.”]  = Common mistake to avoid = For True, False, None we use is and is not for comparisons. They are objects and not values thus we need to use is and is not.  Correct&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;if a: # &amp;quot;a is True&amp;quot;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;br /&gt;
&lt;br /&gt;
[https://docs.python.org/3/library/stdtypes.html#truth-value-testing “Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.”]&lt;br /&gt;
&lt;br /&gt;
= Common mistake to avoid =&lt;br /&gt;
For True, False, None we use is and is not for comparisons. They are objects and not values thus we need to use is and is not.&lt;br /&gt;
&lt;br /&gt;
Correct&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;if a: # &amp;quot;a is True&amp;quot; is shortend to &amp;quot;a&amp;quot; due to the official Python style guidelines&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a is not True:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a is False:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a is not False:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a is None:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a is not None:&lt;br /&gt;
    pass&amp;lt;/syntaxhighlight&amp;gt;Wrong&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;if a == True:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a == False:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a != False:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
if a != None:&lt;br /&gt;
    pass&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not Boolean Operations - and, or, not] ==&lt;br /&gt;
[https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not “These are the Boolean operations, ordered by ascending priority:”]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|x or y&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |if x is false, then y, else x&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |(1)&lt;br /&gt;
|-&lt;br /&gt;
|x or y&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |if x is false, then x, else y&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |(2)&lt;br /&gt;
|-&lt;br /&gt;
|not x&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |if x is false, then True, else False&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |(3)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
# This is a short-circuit operator, so it only evaluates the second argument if the first one is false.&lt;br /&gt;
# This is a short-circuit operator, so it only evaluates the second argument if the first one is true.&lt;br /&gt;
# not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.&lt;br /&gt;
&lt;br /&gt;
== [https://docs.python.org/3/library/stdtypes.html#comparisons Comparisons] ==&lt;br /&gt;
“There are eight comparison operations in Python. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can be chained arbitrarily; for example, x &amp;amp;#x3C; y &amp;amp;#x3C;= z is equivalent to x &amp;amp;#x3C; y and y &amp;amp;#x3C;= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x &amp;amp;#x3C; y is found to be false).”&lt;br /&gt;
&lt;br /&gt;
“This table summarizes the comparison operations:”&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|&amp;amp;#x3C;&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |strictly less than&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |uses method: __lt__()&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;#x3C;=&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |less than or equal&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |uses method: __le__()&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;#x3E;&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |strictly greater than&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |uses method: __gt__()&lt;br /&gt;
|-&lt;br /&gt;
|&amp;amp;#x3E;=&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |greater than or equal&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |uses method: __ge__()&lt;br /&gt;
|-&lt;br /&gt;
|==&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |equal&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |uses method: __eq__()&lt;br /&gt;
|-&lt;br /&gt;
| !=&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |not equal&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
|is&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |object identity&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |&lt;br /&gt;
|-&lt;br /&gt;
|is not&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |negated object identity&lt;br /&gt;
| style=&amp;quot;text-align: center;&amp;quot; |&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Resource ==&lt;br /&gt;
[https://docs.python.org/3/library/stdtypes.html Built-in Types]&lt;/div&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
</feed>