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

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.

Contents