mirror of
https://github.com/Z3Prover/z3
synced 2025-04-20 23:56:37 +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
|
@ -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…
Reference in a new issue