Book Description
Discover clean ways to write code that will run on both Python 2 and 3.This book is tutorial-oriented with detailed examples of how to convert existing Python 2-compatible code to code that will run reliably on both Python 2 and 3.
Although Python 3 is considered the future of Python, Python 2.x will be maintained for several more years, alongside Python 3, which is not backwards compatible. For those who need to support both versions, this book guides you through the process.
Python 2 and 3 Compatibility explains the syntactical differences between Python 2 and 3, and how to use Python packages Python-Future and Six to implement neutral compatibility. Developers working on either small, medium, or large projects will appreciate the author’s clear explanations, detailed examples, and clean techniques to help them extend support for both versions to their existing Python 2-compatible projects.
What You’ll Learn
- Understand the syntactical differences between Python 2 and 3
- Use the Six and Future Libraries
- Review the new features in Python 3
- Choose which Python versions to support when doing neutral support
- Decide on whether to port or provide support for both versions
Who This Book Is For
Professional Python developers and enthusiasts that want to implement Python 3 support for their existing Python 2 compatible code.
Table of Contents
Chapter 1: Printing and Backtick repr
Chapter 2: Numbers
Chapter 3: Setting Metaclasses
Chapter 4: Strings and Bytes
Chapter 5: Package Imports
Chapter 6: Exceptions
Chapter 7: HTML Processing
Chapter 8: Working with Files
Chapter 9: Custom Behavior of Classes
Chapter 10: Collections and Iterators
Chapter 11: More Built-ins
Chapter 12: Standard Library Modules
中文:
书名:Python 2 and 3 Compatibility: With Six and Python-Future Libraries
这本书以教程为导向,详细介绍了如何将现有的与Python2和3兼容的代码转换为能够在Python2和3上可靠运行的代码。
尽管Python3被认为是Python的未来,但与不能向后兼容的Python3一起,Python2.x还将被保留几年。对于需要同时支持这两个版本的用户,本书将指导您完成这一过程。
与Python2和3兼容它解释了Python2和3之间的语法差异,以及如何使用Python包Python-Future和Six来实现中立的兼容性。从事小型、中型或大型项目的开发人员将欣赏作者清晰的解释、详细的示例和干净的技术,以帮助他们将对这两个版本的支持扩展到他们现有的与Python2兼容的项目中。
你会学到什么?
- 了解Python2和3之间的语法差异
- 使用六和未来图书馆
- 查看Python第3版中的新功能
- 选择在执行中立支持时要支持的Python版本
- 决定是否移植两个版本或提供对这两个版本的支持
这本书是为谁写的
专业的开发人员和发烧友,希望为他们现有的、与Python 2兼容的代码实现对Python3的支持。
Table of Contents
第1章:打印和反面标记修复
第二章:数字
Chapter 3: Setting Metaclasses
第4章:字符串和字节
第5章:包裹导入
第6章:例外情况
第7章:超文本标记语言处理
第8章:使用文件
第9章:类的自定义行为
第10章:集合和迭代器
第11章:更多内置功能
第12章:标准库模块
评论前必须登录!
注册