What's the difference between True and False in python grammar?
<p>I'm reading <a href="https://docs.python.org/3/reference/grammar.html" rel="nofollow">the python language specification</a> and found there's a <code>None</code>,
<code>True</code>, and <code>False</code> token. I can understand the difference between <code>None</code> and
<code>False</code> since <code>None</code> is not a boolan. But, about <code>True</code> and <code>False</code>, why not
just <code>BOOLEAN</code> there? Is there any case where <code>True</code> and <code>False</code>
behave differently? Or is there any semantical difference?</p>

<p>Note that I'm asking about the difference in grammar not the boolean value which
is obviously different.</p>

<pre><code>atom: ('(' [yield_expr|testlist_comp] ')' |
       '[' [testlist_comp] ']' |
       '{' [dictorsetmaker] '}' |
       NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
</code></pre>

<p><code>NAME</code>, <code>NUMBER</code>, and <code>STRING</code> are tokens representing three classes of tokens. Each of them represents an unlimited set of possible tokens. There are many number literals that can be classified as <code>NUMBER</code>, many string literals that can be <code>STRING</code>s, etc.</p>

<p>There are only two boolean literals, <code>True</code> and <code>False</code>. The tokenizer could have been written to classify them both as <code>BOOLEAN</code>. Could have, but wasn't. They're only referred to once in the entire grammar, so writing <code>'True' | 'False'</code> is no big deal.</p>

python