Treffer: Support Python 2 and 3 with the same code
Weitere Informationen
(en)Stefan Schwarzer - Support Python 2 and 3 with the same code Your library supports only Python 2, - but your users keep nagging you about Python 3 support? As Python 3 gets adopted more and more, users ask for Python 3 support in existing libraries for Python 2. This talk mentions some approaches for giving users a Python 3 version, but will quickly focus on using the very same code for a Python 2 and a Python 3 version. This is much easier if you require Python 2.6 and up, and yet a bit easier if you require Python 3.3 as the minimum Python 3 version. The talk discusses main problems when supporting Python 3 (some are easily solved): apache-tomcat-10.1.28 bin conf google3d3484531fe2f8a1.html google75618b12b4dbf37f.html internationalization-tool log metadata-dump-transformations metadata-schema.zip nohup.out oersi-backend oersi-etl search-index-import-scripts tomcat `print` is a function. apache-tomcat-10.1.28 bin conf google3d3484531fe2f8a1.html google75618b12b4dbf37f.html internationalization-tool log metadata-dump-transformations metadata-schema.zip nohup.out oersi-backend oersi-etl search-index-import-scripts tomcat More Python APIs return iterators that used to return lists. apache-tomcat-10.1.28 bin conf google3d3484531fe2f8a1.html google75618b12b4dbf37f.html internationalization-tool log metadata-dump-transformations metadata-schema.zip nohup.out oersi-backend oersi-etl search-index-import-scripts tomcat There's now a clear distinction between bytes and unicode (text) strings. apache-tomcat-10.1.28 bin conf google3d3484531fe2f8a1.html google75618b12b4dbf37f.html internationalization-tool log metadata-dump-transformations metadata-schema.zip nohup.out oersi-backend oersi-etl search-index-import-scripts tomcat Files are opened as text by default, requiring an encoding to apply on reading and writing. The talk also explains some best practices: apache-tomcat-10.1.28 bin conf google3d3484531fe2f8a1.html google75618b12b4dbf37f.html internationalization-tool log metadata-dump-transformations ...