This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unicode HOWTO documentation error
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Dionysis.Zindros, docs@python, eric.smith
Priority: normal Keywords:

Created on 2015-01-19 13:56 by Dionysis.Zindros, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg234312 - (view) Author: Dionysis Zindros (Dionysis.Zindros) Date: 2015-01-19 13:56
In the Unicode HOTWO documentation for Python 2.x [0], there's an error in the fourth code sample under the section "The Unicode Type".

The code states:

```
>>> s = u'Was ever feather so lightly blown to and fro as this multitude?'
>>> s.count('e')
5
>>> s.find('feather')
9
>>> s.find('bird')
-1
>>> s.replace('feather', 'sand')
u'Was ever sand so lightly blown to and fro as this multitude?'
>>> s.upper()
u'WAS EVER FEATHER SO LIGHTLY BLOWN TO AND FRO AS THIS MULTITUDE?'
```

Notice that in the last line, "sand" was turned back into "feather". The correct last line should have been:

```
u'WAS EVER SAND SO LIGHTLY BLOWN TO AND FRO AS THIS MULTITUDE?'
```

[0] https://docs.python.org/2/howto/unicode.html
msg234313 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-01-19 14:13
The example is correct. If you type it into a python interpreter, you get the results as shown in the example.

The .replace() method does not modify the string s. It returns the new value. In the example, the new value is displayed, but is not assigned back to s, so s does not change.
History
Date User Action Args
2022-04-11 14:58:12adminsetgithub: 67460
2015-01-19 14:13:54eric.smithsetstatus: open -> closed

type: enhancement ->

nosy: + eric.smith
messages: + msg234313
resolution: not a bug
stage: resolved
2015-01-19 13:56:59Dionysis.Zindroscreate