9 Aug
2002
9 Aug
'02
2:13 p.m.
Since '' in 'abc' now returns True, How about changing 'abc'.replace('') to generate '_a_b_c_', too? It is consistent with re.sub()/subn() and the cost for change is similar to '' in 'abc' case.
Do you have a use case? Or are you just striving for consistency? It would be more consistent but I'm not sure what the point is. I can think of situations where '' in 'abc' would be needed, but not so for 'abc'.replace('', '_'). --Guido van Rossum (home page: http://www.python.org/~guido/)