Skip to content

Instantly share code, notes, and snippets.

@poros
Last active October 5, 2015 22:37
Show Gist options
  • Save poros/ebe1f365e560b7ddcd6b to your computer and use it in GitHub Desktop.
Save poros/ebe1f365e560b7ddcd6b to your computer and use it in GitHub Desktop.
Combine several sets of items
from itertools import product
product(('ENDPOINT1', 'ENDPOINT2'), ('GET', 'POST'), ('200', '404', '500'))
# returns a generator
[('ENDPOINT1', 'GET', '200'), ('ENDPOINT1', 'GET', '404'), ('ENDPOINT1', 'GET', '500'), ('ENDPOINT1', 'POST', '200'), ('ENDPOINT1', 'POST', '404'), ('ENDPOINT1', 'POST', '500'), ('ENDPOINT2', 'GET', '200'), ('ENDPOINT2', 'GET', '404'), ('ENDPOINT2', 'GET', '500'), ('ENDPOINT2', 'POST', '200'), ('ENDPOINT2', 'POST', '404'), ('ENDPOINT2', 'POST', '500')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment