Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created July 14, 2019 15:55
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 eyaltrabelsi/ac4ce89c2d92d326bca034bcc177e6ee to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/ac4ce89c2d92d326bca034bcc177e6ee to your computer and use it in GitHub Desktop.
Python trick Creating an iterator that computes the function using arguments obtained from the iterable of iterables
>>> import itertools
>>> import operator
>>> a = [(2, 6), (8, 4), (7, 3)]
>>> list(itertools.starmap(operator.mul, a))
[12, 32, 21]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment