If you need help writing programs in Python 3, or want to update older Python 2 code, this book is just the ticket. Packed with practical recipes written and tested with Python 3.3, this unique cookbook is for experienced Python programmers who want to focus on modern tools and idioms.
Inside, you’ll find complete recipes for more than a dozen topics, covering the core Python language as well as tasks common to a wide variety of application domains. Each recipe contains code samples you can use in your projects right away, along with a discussion about how and why the solution works.
Topics include:
- Data Structures and Algorithms
- Strings and Text
- Numbers, Dates, and Times
- Iterators and Generators
- Files and I/O
- Data Encoding and Processing
- Functions
- Classes and Objects
- Metaprogramming
- Modules and Packages
- Network and Web Programming
- Concurrency
- Utility Scripting and System Administration
- Testing, Debugging, and Exceptions
- C Extensions
Preface;Who This Book Is For;Who This Book Is Not For;Conventions Used in This Book;Online Code Examples;Using Code Examples;Safari? Books Online;How to Contact Us;Acknowledgments;Chapter 1: Data Structures and Algorithms;1.1 Unpacking a Sequence into Separate Variables;1.2 Unpacking Elements from Iterables of Arbitrary Length;1.3 Keeping the Last N Items;1.4 Finding the Largest or Smallest N Items;1.5 Implementing a Priority Queue;1.6 Mapping Keys to Multiple Values in a Dictionary;1.7 Keeping Dictionaries in Order;1.8 Calculating with Dictionaries;1.9 Finding Commonalities in Two Dictionaries;1.10 Removing Duplicates from a Sequence while Maintaining Order;1.11 Naming a Slice;1.12 Determining the Most Frequently Occurring Items in a Sequence;1.13 Sorting a List of Dictionaries by a Common Key;1.14 Sorting Objects Without Native Comparison Support;1.15 Grouping Records Togetl3Y