Python API

The core of the IDP-Z3 software is a Python component available on Pypi. The following code illustrates how to invoke it.

from idp_engine import IDP, model_expand
kb = IDP.from_file("path/to/file.idp")
T, S = kb.get_blocks("T, S")
for model in model_expand(T,S):
    print(model)

Besides the methods and class available in the main block, idp_engine exposes the IDP class, described below.

IDP class

The IDP class exposes the following methods:

from_file(file_path: str)

This class method parses the IDP source code in the file located at file_path.

from_str(code: str)

This class method parses the IDP source code in the code string.

parse(file_or_string)

DEPRECATED: This class method parses the IDP source code in the file or string.

get_blocks(names)

This instance method returns the list of blocks whose names are given in a comma-separated string.

execute()

This instance methods executes the main() procedure block in the IDP source file.