<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fennec Teaches Python</title>
    <description>The latest articles on DEV Community by Fennec Teaches Python (@fennec_teaches_python).</description>
    <link>https://dev.to/fennec_teaches_python</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4231964%2F46a097bf-e893-41eb-ab1d-ec803bc3d352.jpeg</url>
      <title>DEV Community: Fennec Teaches Python</title>
      <link>https://dev.to/fennec_teaches_python</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fennec_teaches_python"/>
    <language>en</language>
    <item>
      <title>Python's == vs is: the beginner mistake that passes your tests and breaks later</title>
      <dc:creator>Fennec Teaches Python</dc:creator>
      <pubDate>Sat, 07 Nov 2026 11:45:56 +0000</pubDate>
      <link>https://dev.to/fennec_teaches_python/pythons-vs-is-the-beginner-mistake-that-passes-your-tests-and-breaks-later-5bgo</link>
      <guid>https://dev.to/fennec_teaches_python/pythons-vs-is-the-beginner-mistake-that-passes-your-tests-and-breaks-later-5bgo</guid>
      <description>&lt;p&gt;In Python, == and is are two different tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;==&lt;/code&gt; asks: do these two objects have the same VALUE?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;is&lt;/code&gt; asks: are these literally the SAME object in memory?
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# True  -- same value
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# False -- different objects
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why it fools beginners: CPython caches small integers and short strings, so &lt;code&gt;256 is 256&lt;/code&gt; can be True while &lt;code&gt;257 is 257&lt;/code&gt; is False. Your code "works" in the small test and breaks in production.&lt;/p&gt;

&lt;p&gt;THE RULE: Use == for values. Reserve &lt;code&gt;is&lt;/code&gt; for None, True and False — never for numbers or text.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fennec Teaches Python makes 60-second videos on Python mistakes like this one. All 18 fixes are collected in the Python Mistakes Pack: &lt;a href="https://fennecteachespython.gumroad.com/l/yiokvw" rel="noopener noreferrer"&gt;https://fennecteachespython.gumroad.com/l/yiokvw&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
