From f1168d06c0415092c4adc9c2c6917ac5e67a1420 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 11 Apr 2017 17:29:18 +0200 Subject: [#8530] fix octal literals (and remove unwittingly octals) For readability and coherence, in Python 3 the prefix for octal literal becomes ``0o`` (rather than just ``0``). This new version was also added to Python 2 as of 2.6. Convert all octal literals in file-manipulation code (POSIX ACL), and fix a few integers which were unwittingly octal. (lib2to3.fixes.fix_numliterals) --- doc/python3.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc/python3.rst') diff --git a/doc/python3.rst b/doc/python3.rst index b339e0a98b0..4506fb9d9f1 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -109,3 +109,23 @@ Removed/renamed methods ``in`` for dicts was introduced in Python 2.3, leading to ``has_key`` being redundant, and removed in Python 3. + +Minor syntax changes +-------------------- + +* the ability to unpack a parameter (in the parameter declaration list) has + been removed in Python 3 e.g.:: + + def foo((bar, baz), qux): + … + + is now invalid + +* octal literals must be prefixed by ``0o`` (or ``0O``). Following the C + family, in Python 2 an octal literal simply has a leading 0, which can be + confusing and easy to get wrong when e.g. padding for readability (e.g. + ``0013`` would be the decimal 11 rather than 13). + + In Python 3, leading zeroes followed by neither a 0 nor a period is an + error, octal literals now follow the hexadecimal convention with a ``0o`` + prefix. -- cgit v1.2.3