[issue26022] string.replace(' ', ' ') has to be called 2 times before it works

2016-01-06 Thread Ethan Furman

Ethan Furman added the comment:

The .replace() method is not recursive (it only makes one pass through the 
string), so for example:

>>> example = '   '  # three spaces
>>> example = example.replace('  ', ' ')  # replace two spaces with one space
>>> example  # should be two spaces
'  '  
>>> example = example.replace('  ', ' ')  # replace two spaces with one space
>>> example  # should be one space
' '

--
nosy: +ethan.furman
resolution: rejected -> not a bug

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26022] string.replace(' ', ' ') has to be called 2 times before it works

2016-01-06 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Please use stackoverflow or python-tutor list to get help on this.
https://mail.python.org/pipermail/tutor/

This is unlikely a problem as you are using replace the send time on new string 
object.

--
nosy: +orsenthil
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26022] string.replace(' ', ' ') has to be called 2 times before it works

2016-01-06 Thread SilentGhost

SilentGhost added the comment:

Could you provide us with a sample file that demonstrates this behaviour?

--
nosy: +SilentGhost

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26022] string.replace(' ', ' ') has to be called 2 times before it works

2016-01-06 Thread Roland Eichman

New submission from Roland Eichman:

Windows 10 
python 3.5
small function in a small module 
contained a string len(str1) == 5000 {approx}
str1 = str1.replace('  ',' ')
did not work
added, via copy & paste, a second identical line
str1 = str1.replace('  ',' ')
str1 = str1.replace('  ',' ')
AND IT WORKED

--
components: Interpreter Core
messages: 257603
nosy: roland_eichman
priority: normal
severity: normal
status: open
title: string.replace('  ',' ') has to be called 2 times before it works
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com