Best Practices for Returning Variables for Many Outputs

What would be the best practices for returning a bunch of variables to a lot of outputs in a callback? Is there a better way than just typing them all out?

For example, I’m creating a callback that calculates a percent change between two numbers and if it’s positive I return ‘green’ to the color argument of a dmc.Text() along with the value of the percent change. Because of this I have over 100 Outputs. Just curious if anyone has found an optimal way to do this.

I’ve used lists in the past as well, but having to index the list is still cumbersome.


HI @aarondzaboff welcome to the forums.

Are you refering to something like this?

@aarondzaboff - Welcome to Dash! Check out Flexible Callback Signatures | Dash for Python Documentation | Plotly for dictionary-based outputs. Also, you could use a trick locals() to dynamically loop through all the variable names in the function’s scope, but keeping the output variables within a big dictionary would probably be cleaner.