Skip to content

Instantly share code, notes, and snippets.

@ysf
Created July 30, 2014 10:41
Show Gist options
  • Select an option

  • Save ysf/fa2676841263f1206f1b to your computer and use it in GitHub Desktop.

Select an option

Save ysf/fa2676841263f1206f1b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# hack to provide a repeat statement in reply to: https://gist.github.com/ychaouche/f30d5e07012454fff0d2
import inspect
def repeat(count):
if not hasattr(repeat, "loops"):
repeat.loops = {}
index = "%s#%d" % inspect.getouterframes(inspect.currentframe())[-1][1:3]
if index not in repeat.loops:
repeat.loops[index] = count
if repeat.loops[index] < 0:
repeat.loops[index] = count
repeat.loops[index] -= 1
return repeat.loops[index] >= 0
while repeat(2):
while repeat(3):
print "how many times"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment