Python string.Template removes double $
<p>I am using <code>string.Template.safe_substitute(...)</code> to replace keys within a string by a given dictionary. Those strings may contain double <code>$</code> character which I don't want to be replaced because they are not keys.</p>

<p>Given the following example:</p>

<pre><code>&gt;&gt;&gt; Template("foo$$bar").safe_substitute({"key":"val"})
'foo$bar'
</code></pre>

<p>I actualy expected the string to be not changed because <code>key</code> in the dictionary does not match any <code>$key</code> in the given string and the documentation for that function says : </p>

<blockquote>
  <p>the original placeholder will appear in the resulting string intact. Also, unlike with substitute(), any other appearances of the $ will simply return $ instead of raising ValueError.</p>
</blockquote>

<p>But instead one of the <code>$</code> was removed. Why is that? </p>