title: Practical use of tuple as a singleton
body: <p>In the documentation on <a href="https://docs.python.org/2/reference/datamodel.html#the-standard-type-hierarchy" rel="nofollow noreferrer">data models</a> it mentions the possibility to use a single item tuple as a singleton, due to it's immutability.</p>
  <blockquote>
  <p><strong>Tuples</strong></p>
  <p>A tuple of one item (a ‘singleton’) can be formed by affixing a comma
  to an expression...</p>
  </blockquote>
  <p>As far as I understand it in Python, a singleton functions similarly to a constant. It is a fixed value that maintains the same memory address so that you can test either equality or identity. For instance, <code>None</code>, <code>True</code> and <code>False</code> are all builtin singletons.</p>
  <p>However using a tuple defined this way seems impractical for awkward syntax, considering this kind of usage:</p>
  <pre><code>HELLO_WORLD = (&quot;Hello world&quot;,)
  print HELLO_WORLD
  &gt; ('Hello world',)
  print HELLO_WORLD[0]
  &gt; Hello world
  </code></pre>
  <p>Not to mention, it only functions as a singleton if you remember to index it.</p>
  <pre><code>HELLO_WORLD[0] = &quot;Goodbye world&quot;
  
  Traceback (most recent call last):
    File &quot;&lt;pyshell#3&gt;&quot;, line 1, in &lt;module&gt;
      HELLO_WORLD[0] = &quot;Goodbye world&quot;
  TypeError: 'str' object does not support item assignment
  </code></pre>
  <p>Meaning that you could easily do this:</p>
  <pre><code>HELLO_WORLD = &quot;Goodbye world&quot;
  print HELLO_WORLD
  &gt; Goodbye world
  </code></pre>
  <p>Given these limitations, is there any point to this singleton implementation? The only advantage I see is that it's simple to create. Other approaches I've seen have been more complicated approaches (using classes etc.) but is there some other use for this I'm not thinking of?</p>