[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-12 Thread Aurora
Aurora added the comment: @xtreak Understood, just as an aftermath: I still disagree a little with such an implementation because it's riding way into terse-coding that it's going against the principles of mathematics, which is the basis of computer science and programming. Python can use ano

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Pyt

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the details. I looked into the tests for this behavior too and agree it's a tested behavior. issue5416 already had similar discussion and the documentation was committed to be later reverted upon Raymond's suggestion. So I will leave it

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Oops, I meant Lib/test/string_tests.py not "test_string.py". -- ___ Python tracker ___ ___ Pytho

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: Sorry, I disagree that this is a mere implementation detail. The term "implementation detail" normally implies behaviour which occurs *by accident* due to the specific implementation, rather than being intentionally chosen. A good example is early versions

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Steven D'Aprano
Steven D'Aprano added the comment: This behaviour that goes all the way back to Python 1.5, if not older, before strings even had methods: [steve@ando ~]$ python1.5 Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Copyright 1991-1995

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: negative value is an implementation detail where count < 0 is similar to replace all [0]. See also issue5416 [0] https://github.com/python/cpython/blob/43682f1e39a3c61f0e8a638b887bcdcbfef766c5/Objects/unicodeobject.c#L10578 -- nosy: +rhett

[issue39304] Don't accept a negative number for the count argument in str.replace(old, new[, count])

2020-01-11 Thread Aurora
New submission from Aurora : It's meaningless for the count argument to have a negative value, since there's no such thing as negative count for something. -- components: Library (Lib) messages: 359795 nosy: opensource-assist priority: normal severity: normal status: open title: Don't