Return values in Execute OPs

Question about return statements in (chop/dat/etc) Execute operators.

Can I return values so I don’t need to reference an operator in code? I’d like to avoid broken things in case of name changes etc.

As an example, let’s take the DAT Execute OP. Say I want to do some calculation based on a table cell, then return the value to some other chop.

I could do this:

[code]def onCellChange(dat, cells, prev):

do some calculation

sumCols = sum(dat.col(0))
op(‘my_chop’).par.value0 = sumCols
return[/code]

But what I really want is:

[code]def onCellChange(dat, cells, prev):

do some calculation

sumCols = sum(dat.col(0))
return sumCols[/code]

…then connect some wires so there are no op references.

Is this possible? Is there a better way?

Definitely can’t just return a value as you describe.

Sounds like you might want to build a custom component that has an outCHOP you could wire.

I usually resolve use cases like that by writing to op storage and, then use an examine dat to create an op I can get a cable out of.

For what its worth, the return values are not examined when called internally by TouchDesigner.You just need to make sure the name and parameters are correct.

Though as other pointed out, using the functions directly this way may be difficult to manage.

-Rob

Thanks for the insights. Helps me better understand Python in TD.