Propagate Python Functions Downstream

Defining a Python function inside a single Python node means that function is only available inside that node. To create reusable code, your best option is to create a regular Python module, then import that module into each node where you want to use it. Creating a Python module can be surprisingly easy: put your Python functions inside a text file and save it with the file extension ‘.py’. But what if you are never, ever going to use your Python function again except inside this one Workflow? It might feel like overkill to create a Python module if it only has one place where it ever gets used. You could always copy+paste the function definition into each Python node, but this quickly feels less than ideal. This workflow demonstrates how a Python function can be defined in one node, then passed along to other Python nodes via a flow variable. If more than one function needs to be propagated along, create another flow variable to hold each function.

This is a companion discussion topic for the original entry at