[docs] Problem with the documentation for string.replace

Mike Hoy mike at saguaroscuba.com
Sat Sep 29 16:39:40 CEST 2012


> From http://docs.python.org/library/string.html
>
> string.*replace*(/str/, /old/, /new/[, /maxreplace/])¶ 
> <http://docs.python.org/library/string.html#string.replace>
>
> 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.
>
> it would appear this needs to be
>
> string.*replace*(/old/, /new/[, /maxreplace/])¶ 
> <http://docs.python.org/library/string.html#string.replace>
>
> thanks
>


This documentation is correct for this deprecated function. Example:

Python 2.7.3 (default, Aug  1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import string
 >>> string.replace("dog","d","m")
'mog'
 >>>



More information about the docs mailing list