Python 3 шаблоны проектирования

На глаза попалась замечательная книга ("Python 3 Patterns and idioms") от известного среди Java программистов автора - Брюса Эккеля. Книга выложена в открытый доступ вместе с исходниками (чего и стоило ожидать от автора любимой книги). К сожалению многие главы не дописаны, но то, что уже есть - невероятный труд. Книга написано очень давно и сразу видно, что автор ее забросил. Многие вещи, которые описаны как для Python 3 уже имеются для Python 2.7. Сейчас я хочу сделать перевод тех глав, которые уже доступны, выкинуть главу с Jython и дополнить книгу теми разделами, которые там не дописаны. Все это дело буду переносить на платформу runestone, что бы сделать интерактивный учебник как это было с книгой "Решение задач через алгоритмы и структуры данных на Python"

Оглавление учебника

Contributors
Thanks To
ToDo List
The remainder are from context, from the book.
A Note To Readers
Introduction
A Team Effort
Not an Introductory Book
The License
The Printed Book
Translations
My Motives
Teaching Support
Book Development Rules
Contribute What You Can
Don’t Get Attached
Credit
Mechanics
Diagrams
Developer Guide
Getting Started: The Easiest Approach
For Windows Users
Installing Sphinx
Getting the Development Branch of the Book
Building the Book
Building the PDF
Setting up Mercurial
Working with BitBucket and Mercurial
A Simple Overview Of Editing and Merging
Emacs for Editing Restructured Text
Part I: Foundations
Python for Programmers
Scripting vs. Programming
Built-In Containers
Functions
Strings
Classes
Inheritance
Useful Techniques
Further Reading
Initialization and Cleanup
Initialization
Constructor Calls
__new__() vs. __init__()
Static Fields
Cleanup
Further Reading
Unit Testing & Test-Driven Development
Write Tests First
Simple Python Testing
A Very Simple Framework
Writing Tests
White-Box & Black-Box Tests
Running tests
Automatically Executing Tests
Exercises
Python 3 Language Changes
Decorators
Decorators vs. the Decorator Pattern
History of Macros
The Goal of Macros
What Can You Do With Decorators?
Function Decorators
Slightly More Useful
Using Functions as Decorators
Review: Decorators without Arguments
Decorators with Arguments
Decorator Functions with Decorator Arguments
Further Reading
Metaprogramming
Basic Metaprogramming
The Metaclass Hook
The Metaclass Hook in Python 3
Example: Self-Registration of Subclasses
Using Class Decorators
Using the inspect module
Example: Making a Class “Final”
Using __init__ vs. __new__ in Metaclasses
Class Methods and Metamethods
Intercepting Class Creation
A Class Decorator Singleton
The __prepare__() Metamethod
Module-level __metaclass__ Assignment
Metaclass Conflicts
Further Reading
Generators, Iterators, and Itertools
Comprehensions
List Comprehensions
Nested Comprehensions
Techniques
A More Complex Example
Set Comprehensions
Dictionary Comprehensions
Coroutines, Concurrency & Distributed Systems
The GIL
Multiprocessing
Further Reading
Jython
Installation
Getting the Trunk
Scripting
Interpreter Motivation
Creating a Language
Using Java libraries
Inheriting from Java library Classes
Controlling Java from Jython
Inner Classes
Controlling the Interpreter
Putting Data In
Getting Data Out
Multiple Interpreters
Creating Java classes with Jython
Building Java Classes from Python
Summary
Exercises
Part II: Idioms
Discovering the Details About Your Platform
A Canonical Form for Command-Line Programs
Messenger/Data Transfer Object
Part III: Patterns
The Pattern Concept
What is a Pattern?
Classifying Patterns
Pattern Taxonomy
Design Structures
Design Principles
Further Reading
The Singleton
Exercises
Building Application Frameworks
Template Method
Exercises
Fronting for an Implementation
Proxy
State
StateMachine
Table-Driven State Machine
The State Class
Conditions for Transition
Transition Actions
The Table
The Basic Machine
Simple Vending Machine
Testing the Machine
Tools
Exercises
Decorator: Dynamic Type Selection
Basic Decorator Structure
A Coffee Example
Class for Each Combination
The Decorator Approach
Compromise
Other Considerations
Further Reading
Exercises
Iterators: Decoupling Algorithms from Containers
Type-Safe Iterators
Factory: Encapsulating Object Creation
Simple Factory Method
Preventing direct creation
Polymorphic Factories
Abstract Factories
Exercises
Function Objects
Command: Choosing the Operation at Runtime
Strategy: Choosing the Algorithm at Runtime
Chain of Responsibility
Exercises
Changing the Interface
Adapter
Façade
Exercises
Table-Driven Code: Configuration Flexibility
Table-Driven Code Using Anonymous Inner Classes
Observer
Observing Flowers
A Visual Example of Observers
Exercises
Multiple Dispatching
Visitor
Exercises
Pattern Refactoring
Simulating the Trash Recycler
Improving the Design
“Make More Objects”
A Pattern for Prototyping Creation
Trash Subclasses
Parsing Trash from an External File
Recycling with Prototyping
Abstracting Usage
Multiple Dispatching
Implementing the Double Dispatch
The Visitor Pattern
A Reflective Decorator
More Coupling?
RTTI Considered Harmful?
Summary
Exercises
Projects
Rats & Mazes
Other Maze Resources