Functionality - Advanced

Python Expressions

Use inline Python if your task requires functionality exceeding the scope of YAML.

This functionality supports a single Python expression at a time.

Summary

Use the built-in eval action to execute a Python expression.

The output can be saved as a dynamic variable.

Common uses include:

  • Performing calculations
  • Comparing the output of multiple actions

Example

This example compares two lists of Active Directory users.

The lists are both dynamic variables that were saved in previous actions.

An eval action is used to:

  • Find the users in nested_members who aren't in direct_members

  • Save the output as the new nested_only variable

List Comparison
1
2
3
4
actions:
  - eval:
      expression: [user for user in nested_members if user not in direct_members]
    save: nested_only