Conservative Python 3 Porting Guide Documentation Release 1.0 portingguide cont
Conservative Python 3 Porting Guide Documentation Release 1.0 portingguide contributors Mar 30, 2018 Contents 1 The Porting Process 3 1.1 Make Sure your Dependencies are Ported . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Run the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Drop Python 2.5 and Lower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 Port the Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.5 Drop Python 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2 Tools 7 2.1 Compatibility library: six . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 Automated fixer: python-modernize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3 Compatibility headers and guide for C extensions: py3c . . . . . . . . . . . . . . . . . . . . . . . . 8 2.4 Automated checker: pylint --py3k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 Syntax Changes 9 3.1 Tabs and Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2 Tuple Unpacking in Parameter Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3 Backticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.4 The Inequality Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.5 New Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.6 Other Syntax Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4 Exceptions 13 4.1 The new except syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.2 The new raise syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.3 Caught Exception “Scope” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.4 Iterating Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.5 Raising Non-Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.6 The Removed StandardError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.7 Removed sys.exc_type, sys.exc_value, sys.exc_traceback . . . . . . . . . . . . . . 16 5 Importing 17 5.1 Absolute imports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 5.2 import * in Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.3 Import Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6 Standard Library Reorganization 19 6.1 Renamed Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 i 6.2 Removed modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.3 The urllib modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.4 The string module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 7 Numbers 21 7.1 Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 7.2 Unification of int and long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 7.3 Octal Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 8 Strings 25 8.1 The uploads/Litterature/ porting-guide.pdf
Documents similaires










-
51
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Mar 15, 2022
- Catégorie Literature / Litté...
- Langue French
- Taille du fichier 0.3005MB