[New-bugs-announce] [issue40340] Programming FAQ about "How do I convert a string to a number?" contains a typo

Dominik V. report at bugs.python.org
Mon Apr 20 15:37:45 EDT 2020


New submission from Dominik V. <dominik.vilsmeier1123 at gmail.com>:

The paragraph about [How do I convert a string to a number?](https://docs.python.org/3/faq/programming.html#how-do-i-convert-a-string-to-a-number) contains the following sentence:

> By default, these interpret the number as decimal, so that `int('0144') == 144` and `int('0x144')` raises ValueError.

The first part however doesn't raise an error. Most likely octal notation was meant, i.e. `int('0o144') == 144`.

For consistency with the `int('0x144')` part one could also omit the equality comparison, i.e. just write `int('0o144')`.

In order to emphasize that the "and" is not part of the code (though this should be displayed by the browser) once could also write:

> [...] so that _both_ `int('0o144')` and `int('0x144')` raise ValueError.

(emphasis added)

----------
assignee: docs at python
components: Documentation
messages: 366870
nosy: Dominik V., docs at python
priority: normal
severity: normal
status: open
title: Programming FAQ about "How do I convert a string to a number?" contains a typo
type: enhancement
versions: Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40340>
_______________________________________


More information about the New-bugs-announce mailing list