from repo import Repo from contact import Contact my_repo = Repo(Contact) a = Contact("Gudni", "9635354", "*****@*****.**") b = Contact("Lalli", "3453453", "*****@*****.**") c = Contact("Sigga", "2341123", "*****@*****.**") d = Contact("Hannes", "03459533", "*****@*****.**") e = Contact("Gudni", "1234567", "*****@*****.**") my_repo.add(a, b, c, d, e) undo_stack = list() undo_stack.append(((my_repo.remove, (a, b, c, d, e)), )) def undo(): for undo_method, arguments in undo_stack.pop(): undo_method(*arguments) print(my_repo, "\n") undo() print(my_repo) # for item in my_repo.order_by("name"): # print(item) # print() # for item in my_repo.order_by("phone"): # print(item)