Skip to Content
Python Programming with Design Patterns
book

Python Programming with Design Patterns

by James W. Cooper
December 2021
Intermediate to advanced
352 pages
10h
English
Addison-Wesley Professional
Content preview from Python Programming with Design Patterns

27

The State Pattern

The State pattern is used when you want to have an object represent the state of your application and then switch application states by switching objects. For example, you could have an enclosing class switch between a number of related contained classes and then pass method calls on to the current contained class. Design Patterns suggests that the State pattern switch between internal classes in such a way that the enclosing object appears to change its class. In Python, at least, this is a bit of an exaggeration, but the actual purpose to which the classes are put can change significantly.

Many programmers have experienced creating a class that performs slightly different computations or displays different information ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Architecture Patterns

Python Architecture Patterns

Jaime Buelta
Python: Master the Art of Design Patterns

Python: Master the Art of Design Patterns

Dusty Phillips, Chetan Giridhar, Sakis Kasampalis
Architecture Patterns with Python

Architecture Patterns with Python

Harry Percival, Bob Gregory

Publisher Resources

ISBN: 9780137579921