Python.Evaluate
---------------

Evaluates an expression in Python.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Python](component_Python.md) | [14.3](newinversion143.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Python.Evaluate"; PythonRef; Expression ) 

**MBS**( **"Python.Evaluate";** /\* Evaluates an expression in Python. \*/  
**$PythonRef**; /\* The Python reference number.e.g. $python \*/   
**$Expression**) /\* The Python expression.e.g. 1+2 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PythonRef | The Python reference number. | $python |
| Expression | The Python expression. | 1+2 |

### Result

Returns result or error.

### Description

Evaluates an expression in Python.  
Pass an expression to evaluate with Python.  
Returns the result of the expression.  
  
The evaluate runs within the FileMaker process. If you cause an endless loop, FileMaker freezes and needs to be force quit, so please always include an exit condition for your loops. Also if you get Python to crash, FileMaker will crash with it. Use [Shell](component_Shell.md) functions to run Python in a separate process.  
### Examples

Try it:

 Set Variable \[ $r ; Value: MBS ("Python.Evaluate"; $p ; "1+2") \]  
If \[ MBS ("IsError") or $r ≠ 3 \]  
 Show Custom Dialog \[ "Failed to evaluate" ; $r \]  
 Exit Script \[ Text Result: \]  
End If  
### See also

- [IsError](IsError.md)
- [Python.AddEvaluateFunction](PythonAddEvaluateFunction.md)
- [Python.AddExecuteSQLFunction](PythonAddExecuteSQLFunction.md)

### Example Databases

- [Python](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Python.shtml#2ScriptAnchor_)

### Blog Entries

- [Using Python in FileMaker](https://www.mbsplugins.de/archive/2024-06-24/Using_Python_in_FileMaker/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 23th May 2024 , last changed 8th July 2024

  
[Python.DeleteValue](PythonDeleteValue.md) - [Python.GetRecursionLimit](PythonGetRecursionLimit.md)

[HTML Version](PythonEvaluate.shtml)