Partition List Predicate

../../../../_images/partition_list.svg

Partition a list using a configured item-based predicate.

Documentation

This node takes a predicate function (a function that returns True or False) from the configuration and uses it to decide how to partition the output.

The function is applied once for each input element in the list. If it returns True, then the element is written to the first output, otherwise it is written to the second output.

Examples with port type == [table] and item type == table:

Put tables with more than 10 rows in the first output port:

lambda item: item.number_of_rows() > 10

Put nonempty tables in the first output port:

lambda item: not item.is_empty()

The name of the argument is not important.

See https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions for a description of lambda functions. Have a look at the Data type APIs to see what methods and attributes are available on the data type that you are working with.

Definition

Input ports

list
Type: [<a>]
Description: List

Output ports

list_true
Type: [<a>]
Description: List of items where predicate returned true
list_false
Type: [<a>]
Description: List of items where predicate returned false

Configuration

Partition function (predicate)

Function, called for each item in list to determine its output partition. Should return a boolean

Examples

Example flows demonstrating this node:

Implementation

class node_filter_list.PartitionListPredicate[source]