Log In
Or create an account -> 
Imperial Library
  • Home
  • About
  • News
  • Upload
  • Forum
  • Help
  • Login/SignUp

Index
Preface
Who this book is for What this book covers To get the most out of this book Get in touch
Object-Oriented Design
Introducing object-oriented Objects and classes Specifying attributes and behaviors
Data describes object state Behaviors are actions
Hiding details and creating the public interface Composition Inheritance
Inheritance provides abstraction Multiple inheritance
Case study
Introduction and problem overview Context view Logical view Process view Development view Physical view Conclusion
Recall Exercises Summary
Objects in Python
Introducing type hints
Type checking
Creating Python classes
Adding attributes Making it do something
Talking to yourself More arguments
Initializing the object Type hints and defaults Explaining yourself with docstrings
Modules and packages
Organizing modules
Absolute imports Relative imports Packages as a whole
Organizing our code in modules
Who can access my data? Third-party libraries Case study
Logical view Samples and their states Sample state transitions Class responsibilities The TrainingData class
Recall Exercises Summary
When Objects Are Alike
Basic inheritance
Extending built-ins Overriding and super
Multiple inheritance
The diamond problem Different sets of arguments
Polymorphism Case study
Logical view Another distance
Recall Exercises Summary
Expecting the Unexpected
Raising exceptions
Raising an exception The effects of an exception Handling exceptions The exception hierarchy Defining our own exceptions Exceptions aren't exceptional
Case study
Context view Processing view What can go wrong? Bad behavior Creating samples from CSV files Validating enumerated values Reading CSV files Don't repeat yourself
Recall Exercises Summary
When to Use Object-Oriented Programming
Treat objects as objects Adding behaviors to class data with properties
Properties in detail Decorators – another way to create properties Deciding when to use properties
Manager objects
Removing duplicate code In practice
Case study
Input validation Input partitioning The sample class hierarchy The purpose enumeration Property setters Repeated if statements
Recall Exercises Summary
Abstract Base Classes and Operator Overloading
Creating an abstract base class
The ABCs of collections Abstract base classes and type hints The collections.abc module Creating your own abstract base class Demystifying the magic
Operator overloading Extending built-ins Metaclasses Case study
Extending the list class with two sublists A shuffling strategy for partitioning An incremental strategy for partitioning
Recall Exercises Summary
Python Data Structures
Empty objects Tuples and named tuples
Named tuples via typing.NamedTuple
Dataclasses Dictionaries
Dictionary use cases Using defaultdict
Counter
Lists
Sorting lists
Sets Three types of queues Case study
Logical model Frozen dataclasses NamedTuple classes Conclusion
Recall Exercises Summary
The Intersection of Object-Oriented and Functional Programming
Python built-in functions
The len() function The reversed() function The enumerate() function
An alternative to method overloading
Default values for parameters
Additional details on defaults
Variable argument lists Unpacking arguments
Functions are objects, too
Function objects and callbacks Using functions to patch a class Callable objects
File I/O
Placing it in context
Case study
Processing overview Splitting the data Rethinking classification The partition() function One-pass partitioning
Recall Exercises Summary
Strings, Serialization, and File Paths
Strings
String manipulation String formatting
Escaping braces f-strings can contain Python code Making it look right Custom formatters The format() method
Strings are Unicode
Decoding bytes to text Encoding text to bytes Mutable byte strings
Regular expressions
Matching patterns
Matching a selection of characters Escaping characters Repeating patterns of characters Grouping patterns together
Parsing information with regular expressions
Other features of the re module Making regular expressions efficient
Filesystem paths Serializing objects
Customizing pickles Serializing objects using JSON
Case study
CSV format designs CSV dictionary reader CSV list reader JSON serialization Newline-delimited JSON JSON validation
Recall Exercises Summary
The Iterator Pattern
Design patterns in brief Iterators
The iterator protocol
Comprehensions
List comprehensions Set and dictionary comprehensions Generator expressions
Generator functions
Yield items from another iterable Generator stacks
Case study
The Set Builder background Multiple partitions Testing The essential k-NN algorithm k-NN using the bisect module k-NN using the heapq module Conclusion
Recall Exercises Summary
Common Design Patterns
The Decorator pattern
A Decorator example Decorators in Python
The Observer pattern
An Observer example
The Strategy pattern
A Strategy example Strategy in Python
The Command pattern
A Command example
The State pattern
A State example State versus Strategy
The Singleton pattern
Singleton implementation
Case study Recall Exercises Summary
Advanced Design Patterns
The Adapter pattern
An Adapter example
The Façade pattern
A Façade example
The Flyweight pattern
A Flyweight example in Python Multiple messages in a buffer Memory optimization via Python's __slots__
The Abstract Factory pattern
An Abstract Factory example Abstract Factories in Python
The Composite pattern
A Composite example
The Template pattern
A Template example
Case study Recall Exercises Summary
Testing Object-Oriented Programs
Why test?
Test-driven development Testing objectives Testing patterns
Unit testing with unittest Unit testing with pytest
pytest's setup and teardown functions pytest fixtures for setup and teardown More sophisticated fixtures Skipping tests with pytest
Imitating objects using Mocks
Additional patching techniques The sentinel object
How much testing is enough? Testing and development Case study
Unit testing the distance classes Unit testing the Hyperparameter class
Recall Exercises Summary
Concurrency
Background on concurrent processing Threads
The many problems with threads
Shared memory The global interpreter lock Thread overhead
Multiprocessing
Multiprocessing pools Queues The problems with multiprocessing
Futures AsyncIO
AsyncIO in action Reading an AsyncIO future AsyncIO for networking
Design considerations
A log writing demonstration AsyncIO clients
The dining philosophers benchmark Case study Recall Exercises Summary
Other Books You May Enjoy Index
  • ← Prev
  • Back
  • Next →
  • ← Prev
  • Back
  • Next →

Chief Librarian: Las Zenow <zenow@riseup.net>
Fork the source code from gitlab
.

This is a mirror of the Tor onion service:
http://kx5thpx2olielkihfyo4jgjqfb7zx7wxr3sd4xzt26ochei4m6f7tayd.onion