Last active
March 1, 2020 22:13
-
-
Save zambony/4a3e6f63cf71b6e7226c4226d23994c1 to your computer and use it in GitHub Desktop.
Given an array, will stagger printing out the list by splitting it into groups and waiting between each group print
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Timer | |
def chained(iterable, delay = 1.0, groupSize = 10): | |
def anon(arr, size, *args, **kwargs): | |
inc = kwargs["increment"] if "increment" in kwargs else 10 | |
start = kwargs["start"] if "start" in kwargs else 0 | |
finish = kwargs["finish"] if "finish" in kwargs else inc | |
if (finish >= size): | |
finish = size | |
s = "" | |
for entry in arr[start:finish]: | |
s += str(entry) + "\n" | |
print(s) | |
if (start + inc >= size): | |
return | |
timer = Timer(delay, anon, [arr, size], {"increment": inc, "start": start + inc, "finish": finish + inc}) | |
timer.start() | |
anon(iterable, len(iterable), increment = groupSize) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment