Skip to content

Instantly share code, notes, and snippets.

@andrewebdev
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewebdev/e3a979cfb46380884f3a to your computer and use it in GitHub Desktop.
Save andrewebdev/e3a979cfb46380884f3a to your computer and use it in GitHub Desktop.
# The long, slightly incorrect method...
def looper(count, depth, *args):
"""
No this does not allow you to go back in time
@param count: number of iterations per loop
@param depth: number of loops
"""
for i in range(count):
if depth > 0:
args += (i + 1,)
looper(count, depth - 1, *args)
else:
# Do something with all the args passed thus far
print args
looper(2, 2)
# Here follows the _correct_ way to do this, as presented by Tom Dalton on the mailing list
import itertools
for i in itertools.product(range(10), repeat=10):
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment