Python in Practice
Douban
Create Better Programs Using Concurrency, Libraries, and Patterns
Mark Summerfield
overview
Python in Practice presents Python programming technologies and techniques to help programmers write code that's elegant, maintainable, and fast. Drawing on both the standard library and important third-party libraries, the book shows how to achieve significant speedups using high-level concurrency and compiled Python. The book is packed with examples and ideas that illustrate a wide range of techniques and modules, encompassing high-level networking, 2D graphics, 3D graphics, and GUI programming---including concurrent GUI programming. The book is aimed at programmers who want to take their Python programming to the next level.
contents
Table of Contents
Foreword by Doug Hellmann
Introduction
Acknowledgements
Chapter 1. Creational Design Patterns
Abstract Factory Pattern
A Classic Abstract Factory
A More Pythonic Abstract Factory
Builder Pattern
Factory Method Pattern
Prototype Pattern
Singleton Pattern
Chapter 2. Structural Design Patterns
Adapter Pattern
Bridge Pattern
Composite Pattern
A Classic Composite/Noncomposite Hierarchy
A Single Class for (Non)Composites
Decorator Pattern
Function and Method Decorators
Class Decorators
Facade Pattern
Flyweight Pattern
Proxy Pattern
Chapter 3. Behavioral Design Patterns
Chain of Responsibility Pattern
A Conventional Chain
A Coroutine-based Chain
Command Pattern
Interpreter Pattern
Expression Evaluation with eval()
Code Evaluation with exec()
Code Evaluation using a Subprocess
Iterator Pattern
Sequence Protocol Iterators
Two-argument iter() Function Iterators
Iterator Protocol Iterators
Mediator Pattern
A Conventional Mediator
A Coroutine-based Mediator
Memento Pattern
Observer Pattern
State Pattern
Using State-Sensitive Methods
Using State-Specific Methods
Strategy Pattern
Template Method Pattern
Visitor Pattern
Case Study: An Image Package
Chapter 4. High-Level Concurrency
CPU-bound Concurrency
Using Queues and Multiprocessing
Using Futures and Multiprocessing
I/O-bound Concurrency
Using Queues and Threading
Using Futures and Threading
Case Study: A Concurrent GUI Application
Chapter 5. Extending Python
Accessing C Libraries with ctypes
Using Cython
Accessing c Libraries with Cython
Writing Cython Modules for Greater Speed
Case Study: An Accelerated Image Package
Chapter 6. High-Level Networking
Writing XML-RPC Applications
A Data Wrapper
Writing XML-RPC Servers
Writing XML-RPC Clients
Writing RPyC Applications
A Thread-Safe Data Wrapper
Writing RPyC Servers
Writing RPyC Clients
Chapter 7. Graphical User Interfaces with Tkinter
Introduction to Tkinter
Creating Dialogs with Tkinter
Creating a Dialog-style Application
Creating Application Dialogs
Creating Main Window Applications with Tkinter
Creating a Main Window
Creating Menus
Creating a Status Bar with Indicators
Chapter 8. OpenGL 3D Graphics
A Perspective Scene
Creating a Cylinder with PyOpenGL
Creating a Cylinder with pyglet
An Orthographic Game
Drawing the Board Scene
Handling Scene Object Selection
Handling User Interaction
Appendix A: Epilogue
Appendix B: Selected Bibliograpy
Index