mirror of
https://github.com/Z3Prover/z3
synced 2026-02-21 15:57:35 +00:00
Add __enter__ and __exit__ methods on Optimize class
This enables the use of the with statement for the Optimize class to concisely call push() and pop(). This works similarly to the Solver class.
This commit is contained in:
parent
1e5c59a06f
commit
c9ce32ddff
1 changed files with 7 additions and 0 deletions
|
|
@ -7991,6 +7991,13 @@ class Optimize(Z3PPObject):
|
|||
if self._on_models_id is not None:
|
||||
del _on_models[self._on_models_id]
|
||||
|
||||
def __enter__(self):
|
||||
self.push()
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc_info):
|
||||
self.pop()
|
||||
|
||||
def set(self, *args, **keys):
|
||||
"""Set a configuration option.
|
||||
The method `help()` return a string containing all available options.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue