Python blocks in workflow to return multiple outputs


I have a question around the use of Python in workflow.

Let's say I have an input number, and I want to both create a table AND a chart from it, and show both in the retool app. Is it possible to do it in the same workflow? And if I use 1 Python block to create a table, and link to weebhookReturn1, can I link the table to another Python block for some more transformations?

Hey @!

Yes! You should be able to run multiple code blocks and have them all be accessible. This can either be in parallel:

Or sequentially:

Either way, the result of both blocks will be in scope for the response block. You can read more about using code blocks here, let me know if that helps! Also curious to hear more about your use case :slightly_smiling_face:

Hi Kabirdas,

Thanks for you reply. I'm interested in both actually.
For example, here is my example use case:

I want to take a number from the app (call it x), run a table shows the values of squares from 1 to x, and draw a chart to show the square curve.

Ideally, i want to pass the "df" from GenerateRange down to Chart, instead of having to recalculate, and want to pass both the df and the chart to the Response block to be shown again in the app.

Can you advise how?

I have managed to do the 2nd part, which is passing both the df and the chart to the response block with the following:


Blocks don't need to be directly linked to pass along their values, they just need to exist somewhere further up in the chain. If you run them sequentially both results should be available in the last block:

Does that work?

Aha this is why I was struggling: "Blocks don't need to be directly linked to pass along their values". Now it's all good, make the workflow simpler as well.

Thanks a lot!

1 Like