Constant name0 me.digits

Hi,

In Execute DAT I’m trying to make Constant chop’s par - name0, name1, name2 and so on… to correspond with op’s digits
Something like:

op(‘constant1’).par.name0 <<<this number, to be equal me.parent(2).digits number.
Is there a method where i could somehow add these two, like it’s done in a string:
‘name’ + str(me.parent(2).digits) = ‘name1’ ???

Thanks :slight_smile:

use the Python getattr and setattr methods.

getattr(op('constant1').par, "name" + str(me.parent(2).digits) ) 

Search getattr Python docs for more detailed info.

1 Like

Thats definitely a good tool in general, but you might also use:

OP.pars(patternString) which returns a list of parameters by pattern/name.

docs.derivative.ca/OP_Class#General_2

in this case:

op(‘constant1’).pars( ‘name’ + str(me.parent(2).digits)[0] #return first matching parameter

Great, thanks for that nettoyeur and Rob.