[issue28029] Replace and empty strings

Stéphane Henriot report at bugs.python.org
Thu Sep 8 16:54:18 EDT 2016


Stéphane Henriot added the comment:

Thanks for your help.

However, I'm not sure I would agree, regarding the correct behavior.

I guess the main question is « What is an occurrence? ».

Are you not convinced that in, count and find indicate occurrences?
To my understanding, the empty string occurs basically everywhere in strings (including beginning and end):

>>> "blabla".replace("", "ε")
'εbεlεaεbεlεaε'

To give a bit more (useless?) context, I was implementing a GCD algorithm based on replacements by Knuth (very beginning of TAOCP) and it looks like the current cpython implementation gives 0 for gcd(1, 1) :(

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28029>
_______________________________________


More information about the Python-bugs-list mailing list