title: What is the correct form for string.replace?
body: <p>Following the Python documentation for string.replace ( <a href="http://docs.python.org/library/string.html" rel="nofollow noreferrer">http://docs.python.org/library/string.html</a> ):</p>
  <blockquote>
  <p>string.replace(str, old, new[, maxreplace])</p>
  <p>Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, the first maxreplace occurrences are replaced.</p>
  </blockquote>
  <p>Using the format as given generates the following error:</p>
  <pre><code>&gt;&gt;&gt; a = 'grateful'
  &gt;&gt;&gt; a.replace(a,'t','c')
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  TypeError: an integer is required
  </code></pre>
  <p>It seems odd that you'd need the &quot;str&quot; repeated and from the error I guessed that my third argument was being taken for maxreplace.</p>
  <p>The format:</p>
  <blockquote>
  <p>string.replace(old, new)</p>
  </blockquote>
  <p>does seem to function as expected.</p>
  <p>I'm wondering if I am misunderstanding something, and the form given in the Python documentation is, in fact, correct in some way.</p>