[docs] [issue29751] PyLong_FromString documentation wrong on numbers with leading zero and base=0

Martin Panter report at bugs.python.org
Sat Apr 1 23:20:32 EDT 2017


Martin Panter added the comment:

Underscores are only applicable to 3.6+, but the original concern about leading zeros applies to 3.5.

On Git Hub I suggested dropping the details and just referring to the Lexical Analysis section <https://docs.python.org/3.5/reference/lexical_analysis.html#integer-literals> for the details.

FWIW here is my understanding of integer literals (with base=0):

* 0x10 => hexadecimal
* 0b10 => binary
* 0o10 => octal (corresponds to 010 in Python 2)
* 01 => illegal (avoids conflict with Python 2)
* 00 => zero (special case; was treated as octal zero in Python 2)
* 10 => decimal (must not start with digit 0)

If you want to spell out the rules, in my mind there are four special prefixes, 0x, 0b, 0o and 0, and the default is decimal if none of those prefixes apply.

----------

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


More information about the docs mailing list