54.5 Python Syntax Errors

Models which use Python will also return error messages if there is an error in the Python script.

The example in the Special Features tutorial example model, Python Example – SyntaxError.trex, has invalid Python code within the variable definition for function PythonFunctionSyntaxError. Specifically, the internal Python variable missing_input is not declared within the function or passed as an argument to the function. Therefore, when missing_input is referenced, an error is thrown.

Rolling back the model creates the error message shown in the figure below identifying where the error in the Python function is, specifically line 5 where missing_input is referenced but was never defined.

If your Python function has invalid syntax, an error like the one above should help you resolve the issue.