classification
Title: fix documentation of string.replace() signature
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, chris.jerdonek, docs@python
Priority: normal Keywords: easy

Created on 2012-09-28 03:28 by chris.jerdonek, last changed 2012-09-28 13:36 by asvetlov. This issue is now closed.

Messages (6)
msg171404 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-09-28 03:28
> Date: Thu, 13 Sep 2012 09:42:47 -0400
> To: <docs@python.org>
> Subject: [docs] Problem with the documentation for string.replace
>
> >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>

(from: http://mail.python.org/pipermail/docs/2012-September/010521.html )
msg171446 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-09-28 12:16
No it shoudn't.
It works exactly as described:
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.
*str* is updated string and it is definitelly required.
msg171447 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-09-28 12:24
Thanks, Andrew.  I didn't look closely enough when reading the e-mail or I wouldn't have posted.  I had assumed from the e-mail that this was in the string *method* section rather than string module.
msg171449 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2012-09-28 12:37
[Reopening] It looks like at least *some* change is warranted here.  Notice that all the functions document "s" for the string argument but string.replace() documents "str".  However, we have (in 2.7):

>>> string.replace(str='aab', old='a', new='b')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: replace() got an unexpected keyword argument 'str'
>>> string.replace(s='aab', old='a', new='b')
'bbb'
msg171451 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-09-28 12:47
If you want just to change parameter name in the docs — I'm ok with that.
msg171462 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-09-28 13:36
Fixed in c34a177d1f38
History
Date User Action Args
2012-09-28 13:36:17asvetlovsetstatus: open -> closed
resolution: fixed
messages: + msg171462

stage: needs patch -> resolved
2012-09-28 12:47:21asvetlovsetmessages: + msg171451
2012-09-28 12:37:02chris.jerdoneksetstatus: closed -> open
resolution: not a bug -> (no value)
messages: + msg171449

stage: resolved -> needs patch
2012-09-28 12:24:41chris.jerdoneksetmessages: + msg171447
2012-09-28 12:16:41asvetlovsetstatus: open -> closed

nosy: + asvetlov
messages: + msg171446

resolution: not a bug
stage: needs patch -> resolved
2012-09-28 03:28:48chris.jerdonekcreate