title: checking for empty strings using `is`
body: <p>Is it correct to check for empty strings using <code>is</code> in Python? It does identity checking, while <code>==</code> tests equality.</p>
  
  <p>Consider the following (the idea of using <code>join</code> is borrowed from <a href="https://stackoverflow.com/a/1504742/493928">this answer</a>):</p>
  
  <pre><code>&gt;&gt;&gt; ne1 = "aaa"
  &gt;&gt;&gt; ne2 = "".join('a' for _ in range(3))
  &gt;&gt;&gt; ne1 == ne2
  True
  &gt;&gt;&gt; ne1 is ne2
  False
  &gt;&gt;&gt;
  </code></pre>
  
  <p>so here <code>is</code> works as one may expect. Now take a look at this code:</p>
  
  <pre><code>&gt;&gt;&gt; e1 = ""
  &gt;&gt;&gt; e2 = "aaa".replace("a", "")
  &gt;&gt;&gt; e3 = "" * 2
  &gt;&gt;&gt; e4 = "bbb".join(range(0))
  &gt;&gt;&gt; e1, e2, e3, e4
  ('', '', '', '')
  &gt;&gt;&gt; e1 is e2
  True
  &gt;&gt;&gt; e1 is e3
  True
  &gt;&gt;&gt; e1 is e4
  True
  &gt;&gt;&gt; id(e1), id(e2), id(e3), id(e4)
  (35963168, 35963168, 35963168, 35963168) # why?
  </code></pre>