Rotating return value by ratio function the pythonista way
I have a function return value rotate by ratio as setup, currently I use a
thing like priority queue to make this work but what is these a good
performance and pythonista way to do this.
This is example of how I need my function work
I have setup:
value | ratio
A 2
B 1
C 3
and a function use that setup:
setup = {'A': 2, 'B': 1, 'C': 3} #create from setup above
def process():
...
value = ...
return value
result when call function:
process()
>>> A
process()
>>> A
process()
>>> B
process()
>>> C
process()
>>> C
process()
>>> C
process()
>>> A
process()
>>> A
process()
>>> B
...
No comments:
Post a Comment