Book description
Mark Pilgrim's Dive Into Python 3 is a hands-on guide to Python 3 and its differences from Python 2. As in the original book, Dive Into Python, each chapter starts with a real, complete code sample, proceeds to pick it apart and explain the pieces, and then puts it all back together in a summary at the end.
This book includes:
- Example programs completely rewritten to illustrate powerful new concepts now available in Python 3: sets, iterators, generators, closures, comprehensions, and much more
- A detailed case study of porting a major library from Python 2 to Python 3
- A comprehensive appendix of all the syntactic and semantic changes in Python 3
This is the perfect resource for you if you need to port applications to Python 3, or if you like to jump into languages fast and get going right away.
Table of contents
- Title page
- Copyright Page
- Contents at a Glance
- Table of Contents (1/2)
- Table of Contents (2/2)
- Foreword
- About the Author
- About the Technical Reviewer
- Acknowledgments
-
Installing Python
- Which Python Is Right for You?
- Installing on Microsoft Windows (1/2)
- Installing on Microsoft Windows (2/2)
- Installing on Mac OS X (1/3)
- Installing on Mac OS X (2/3)
- Installing on Mac OS X (3/3)
- Installing on Ubuntu Linux (1/2)
- Installing on Ubuntu Linux (2/2)
- Installing on Other Platforms
- Using the Python Shell
- Python Editors and IDEs
- CHAPTER 1 Your First Python Program
- CHAPTER 2 Native Datatypes
- CHAPTER 3 Comprehensions
- CHAPTER 4 Strings
- CHAPTER 5 Regular Expressions
- CHAPTER 6 Closures and Generators
- CHAPTER 7 Classes and Iterators
-
CHAPTER 8 Advanced Iterators
- Finding All Occurrences of a Pattern
- Finding the Unique Items in a Sequence
- Making Assertions
- Generator Expressions
- Calculating Permutations … the Lazy Way
- Other Fun Stuff in the itertools Module
- A New Kind of String Manipulation
- Evaluating Arbitrary Strings as Python Expressions
- Putting It All Together
- Further Reading Online
- CHAPTER 9 Unit Testing
- CHAPTER 10 Refactoring
- CHAPTER 11 Files
- CHAPTER 12 XML
-
CHAPTER 13 Serializing Python Objects
- A Quick Note About the Examples in this Chapter
- Saving Data to a Pickle File
- Loading Data from a Pickle File
- Pickling Without a File
- Bytes and Strings Rear Their Ugly Heads Again
- Debugging Pickle Files
- Serializing Python Objects to be Read by Other Languages
- Saving Data to a JSON File
- Mapping Python Datatypes to JSON
- Serializing Datatypes Unsupported by JSON
- Loading Data from a JSON File
- Further Reading Online
- CHAPTER 14 HTTP Web Services
-
CHAPTER 15 Case Study: Porting chardet to Python 3
- What Is Character Encoding Auto-Detection?
- Introducing the chardet Module
- Running 2to3
- A Short Digression Into Multi-File Modules
- Fixing What 2to3 Can’t (1/4)
- Fixing What 2to3 Can’t (2/4)
- Fixing What 2to3 Can’t (3/4)
-
Fixing What 2to3 Can’t (4/4)
- False Is Invalid Syntax
- No Module Named Constants
- Name 'file' Is Not Defined
- Can’t Use a String Pattern on a Bytes-Like Object
- Can’t Convert 'bytes' Object to str Implicitly
- Unsupported Operand type(s) for +: 'int' and 'bytes'
- ord() Expected String of Length 1, but int Found
- Unorderable Types: int() >= str()
- Global Name 'reduce' Is not Defined
- Lessons Learned
- CHAPTER 16 Packaging Python Libraries
-
APPENDIX A Porting Code to Python 3 with 2to3
- print Statement
- Unicode String Literals
- unicode() Global Function
- long Datatype
- <> Comparison
- has_key() Dictionary Method
- Dictionary Methods that Return Lists
- Renamed or Reorganized Modules
- Relative Imports Within a Package
- next() Iterator Method
- filter() Global Function
- map() Global Function
- reduce() Global Function
- apply() Global Function
- intern() Global Function
- exec Statement
- execfile Statement
- repr Literals (Backticks)
- try...except Statement
- raise Statement
- throw Method on Generators
- xrange() Global Function
- raw_input() and input() Global Functions
- func_* Function Attributes
- xreadlines() I/O Method
- lambda Functions that Take a Tuple Instead of Multiple Parameters
- Special Method Attributes
- __nonzero__ Special Method
- Octal Literals
- sys.maxint
- callable() Global Function
- zip() Global Function
- StandardError Exception
- types Module Constants
- isinstance() Global Function
- basestring Datatype
- itertools Module
- sys.exc_type, sys.exc_value, sys.exc_traceback
- List Comprehensions Over Tuples
- os.getcwdu() Function
- Metaclasses
- Matters of Style
-
APPENDIX B Special Method Names
- Basics
- Classes that Act Like Iterators
- Computed Attributes
- Classes that Act Like Functions
- Classes that Act Like Sequences
- Classes that Act Like Dictionaries
- Classes that Act Like Numbers
- Classes that Can Be Compared
- Classes that Can Be Serialized
- Classes that Can Be Used in a “with” Block
- Really Esoteric Stuff
- Further Reading Online
- APPENDIX C Where to Go From Here
- Index (1/3)
- Index (2/3)
- Index (3/3)
Product information
- Title: Dive Into Python 3
- Author(s):
- Release date: March 2010
- Publisher(s): Apress
- ISBN: None
You might also like
book
Python Standard Library
Python Standard Library is an essential guide for serious Python programmers. Python is a modular language …
video
Python Devops in TWO HOURS!
Python Devops in TWO HOURS!
book
Learning Python Networking - Second Edition
Achieve improved network programmability and automation by leveraging powerful network programming concepts, algorithms, and tools Key …
book
The Python 3 Standard Library by Example, Second Edition
Master the Powerful Python 3 Standard Library through Real Code Examples "The genius of Doug's approach …