Executable

class Executable(code: str, *, file_name: str = '<string>')

An Executable is a script that can be executed with exec(). These allow for arbitrary execution of code when running a PythonRule.

When evaluated, a context can be provided that gets passed to the :func`globals` parameter of the exec() function, which can then later be used during evaluation of an Evaluatable if modules are imported or variables are set.

Parameters:
  • code – The script to be evaluated.

  • file_name – A file name used when compiling the script, which can be helpful during error handling and bug fixing (see compile()).

Methods

execute

Execute this code.

execute(global_context: dict = None) None

Execute this code.

Parameters:

global_context – A dictionary representing globals() when executing the code with exec().