From the course: Python: Advanced Design Patterns
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Memento - Python Tutorial
From the course: Python: Advanced Design Patterns
Solution: Memento
- [Instructor] How was the code challenge? We already instantiated an originator here. To take a snapshot, let's invoke the create_memento method by typing originator .create _memento. Type last _snapshot, space, assignment, space to store the last snapshot in the variable. After changing the virtual machine or VM state, let's restore the VM to the last snapshot by typing originator .set _memento and then in between the parentheses last _snapshot. That's all you have to do. Now we're ready to press the Test my code button. We did it again. Congratulations.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Mediator2m 11s
-
(Locked)
Mediator example7m 29s
-
(Locked)
Memento2m 16s
-
(Locked)
Memento example4m 46s
-
(Locked)
Solution: Memento1m 43s
-
(Locked)
State2m 11s
-
(Locked)
State example5m 44s
-
(Locked)
Solution: State53s
-
(Locked)
Template method2m 17s
-
(Locked)
Template method example6m 35s
-
Solution: Template1m 14s
-
(Locked)
Practitioner's perspective: Development2m 5s
-
(Locked)
-