Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
Created June 15, 2016 18:26
Show Gist options
  • Save sangheestyle/6c681ab182ca09aabdd612c512432c0e to your computer and use it in GitHub Desktop.
Save sangheestyle/6c681ab182ca09aabdd612c512432c0e to your computer and use it in GitHub Desktop.
def repeat(object, times=None):
# repeat(10, 3) --> 10 10 10
if times is None:
while True:
yield object
else:
for i in range(times):
yield object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment