Read more
Python in Practice presents Python programming technologies and techniques to help programmers write code that is 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.
List of contents
Foreword xiii
Introduction 1
Acknowledgments 3
Chapter 1: Creational Design Patterns 5
1.1. Abstract Factory Pattern 5
1.2. Builder Pattern 11
1.3. Factory Method Pattern 17
1.4. Prototype Pattern 24
1.5. Singleton Pattern 26
Chapter 2: Structural Design Patterns 29
2.1. Adapter Pattern 29
2.2. Bridge Pattern 34
2.3. Composite Pattern 40
2.4. Decorator Pattern 48
2.5. Fa'ade Pattern 59
2.6. Flyweight Pattern 64
2.7. Proxy Pattern 67
Chapter 3: Behavioral Design Patterns 73
3.1. Chain of Responsibility Pattern 74
3.2. Command Pattern 79
3.3. Interpreter Pattern 83
3.4. Iterator Pattern 95
3.5. Mediator Pattern 100
3.6. Memento Pattern 106
3.7. Observer Pattern 107
3.8. State Pattern 111
3.9. Strategy Pattern 116
3.10. Template Method Pattern 119
3.11. Visitor Pattern 123
3.12. Case Study: An Image Package 124
Chapter 4: High-Level Concurrency 141
4.1. CPU-Bound Concurrency 144
4.2. I/O-Bound Concurrency 155
4.3. Case Study: A Concurrent GUI Application 164
Chapter 5: Extending Python 179
5.1. Accessing C Libraries with ctypes 180
5.2. Using Cython 187
5.3. Case Study: An Accelerated Image Package 198
Chapter 6: High-Level Networking 203
6.1. Writing XML-RPC Applications 204
6.2. Writing RPyC Applications 219
Chapter 7: Graphical User Interfaces with Tkinter 231
7.1. Introduction to Tkinter 233
7.2. Creating Dialogs with Tkinter 235
7.3. Creating Main-Window Applications with Tkinter 253
Chapter 8: OpenGL 3D Graphics 263
8.1. A Perspective Scene 264
8.2. An Orthographic Game 272
Appendix A: Epilogue 283
Appendix B: Selected Bibliography 285
Index 289
About the author
Mark Summerfield, owner of Qtrac Ltd., is an independent trainer, consultant, technical editor, and writer specializing in C++, Go, Python, Qt, and PyQt. His books include Rapid GUI Programming with Python and Qt; C++ GUI Programming with Qt 4, Second Edition (with Jasmin Blanchette); Programming inPython 3, Second Edition; and Advanced Qt Programming, and Programming in Go, all from Addison-Wesley.
Summary
"First printing, August 2013"--Title page verso.