Closed jpk0727 closed 6 years ago
Hi, you can use the "alt"-method, e.g.
from pyschedule import alt T += alt([ R[i] for i in range(n) ]) On Jan 10, 2017 5:09 PM, "Jess Karol" notifications@github.com wrote:
Hi,
I am attempting to assign a variable amount of optional resources to a task in a loop like so:
T += R[0] | R[1] | R[2] | ... | R[n]
However, adding R as an array creates multiple tasks. For example, this does not achieve the desired result:
T += R
A solution I came up with that works is by creating a string in a loop the is the command I would like to executue and the calling the exec() function like so...
exec_str = "T[i] +=" for i in range(len(R)): exec_str+=" R["+str(i)+"] " if (i != len(R) - 1): exec_str+= "|" exec(exec_str)
This solution, however, seems pretty ugly to me. Anybody see any better alternatives?
Thanks, Jess
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/timnon/pyschedule/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AFVo1ZTOPo22sez4r5osNPdaVNwQfoLpks5rQ60lgaJpZM4Lflsq .
Hi,
I am attempting to assign a variable amount of optional resources to a task in a loop like so:
T += R[0] | R[1] | R[2] | ... | R[n]
However, adding R as an array creates multiple tasks. For example, this does not achieve the desired result:
T += R
A solution I came up with that works is by creating a string in a loop the is the command I would like to executue and the calling the exec() function like so...
This solution, however, seems pretty ugly to me. Anybody see any better alternatives?
Thanks, Jess