A
Aaron Brady
Hello,
I am writing a generator to return a sequence of numbers with some
variation. The parameters of the variation can be changed by the
caller, even after the generator is started. My question is, is it
better to wrap the generator in an object, so that the parameters can
be changed just by an attribute access? Or keep the generator clear,
and modify parameters with a 'send' call?
P.S. It would receive the 'send' from a different point in control
flow than its usual 'next'. Should it repeat a value if it receives a
'send'? Or should I wrap it in a secondary 'trap_send_and_repeat'
generator?
Thanks sincerely as always.
I am writing a generator to return a sequence of numbers with some
variation. The parameters of the variation can be changed by the
caller, even after the generator is started. My question is, is it
better to wrap the generator in an object, so that the parameters can
be changed just by an attribute access? Or keep the generator clear,
and modify parameters with a 'send' call?
P.S. It would receive the 'send' from a different point in control
flow than its usual 'next'. Should it repeat a value if it receives a
'send'? Or should I wrap it in a secondary 'trap_send_and_repeat'
generator?
Thanks sincerely as always.