2

I hope this is a easy one.

Is there any possiblity to call itertools.product with a yet (not hardcoded) not knwon number of arguments?

Something like this:

itertools.product(x[0],x[1],x[2],....)

and the dimension of x can't be hardcoded

Thanks!

sklingel
  • 169
  • 2
  • 9

3 Answers3

3

Try:

itertools.product(*x)

i.e. we unpack the argument list.

arshajii
  • 127,459
  • 24
  • 238
  • 287
2

You can use

itertools.product(*x)
Phae7rae
  • 524
  • 2
  • 4
  • 14
1

Lookup *args and **kwargs?

a = [1,2,3]
b = [2,3,4]
c= [a,b]

itertools.product(*c)

You can pass array of arguments using *

Community
  • 1
  • 1
Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96