SitePoint
  • Premium
  • Library
  • Community
  • Jobs
  • Blog
LoginStart Free Trial
The Python Master
The Python Master
Preface
Errata and Suggestions
Conventions Used in This Book
Welcome!
Prerequisites
The Road Goes On Forever

1

Advanced Flow Control

else clauses on loops
An alternative to loop else clauses
The try..except..else construct
Emulating switch
Dispatching on Type
singledispatch
Summary
Bitwise operators
The bytes type in depth
The mutable bytearray sequence
Interpreting byte streams with the struct module
Memory Views
Memory-mapped files
Summary
How are Python objects stored?
Using vars() to access __dict__
Overriding __getattribute__()
Special methods which bypass __getattribute__()
Where are the methods?
Slots
A review of properties
Unravelling the property function
Implementing a descriptor
Retrieving descriptors on classes
Data versus non-data descriptors
Summary
Instance Creation
Customising allocation
Summary
The class of class objects
Class allocation and initialisation
Passing additional arguments to the metaclass
Metaclass methods and visibility
Fine-grained instantiation control with metaclass __call__()
Practical metaclass examples
Metaclasses and Inheritance
Summary
A first class decorator
Enforcing constraints with a class decorator
Enforcing constraints for properties
Chaining class decorators
Summary
What is an abstract base-class?
Why are abstract base-classes useful?
What about duck typing?
Abstract base-classes in Python
Defining subclasses with __subclasscheck__()
Non-transitivity of subclass relationships
Library support for abstract base-classes
Combining abstractmethod with other decorators
Propagating abstractness through descriptors
Fixing our @invariant class decorator with ABCs
Summary

Abstract Base Classes

Unlock This Title

You do not have access to this section. Get the full version of this title with a SitePoint Premium Account.

Start Free TrialRead Free Preview

Already a Premium member? Sign In

Community Questions