0

I have a tuple/list like so:

tup = (1, 2, 3, 4, 5)
f = [ (e, d, c, b, a) for a in tup for b in tup for c in tup for d in tup for e in tup ]

How do I create an equivalent array directly from NumPy without using np.array( f )? Is there some slicing technique that I should use on tup? Is what I am asking for possible?

I am specifically asking if NumPy can do this directly, for e.g via some slicing technique or some NumPy function, without using other python functions. I am trying to better understand the capabilities of NumPy.

Thank you.

Sun Bear
  • 7,594
  • 11
  • 56
  • 102

1 Answers1

0

you can use itertools.

import itertools
tup = (1,2,3,4,5)
list(itertools.product(tup, repeat=5))
Florian H
  • 3,052
  • 2
  • 14
  • 25
  • Thank you but this answer is not what I am looking for. I am specifically asking if numpy can do this directly, for e.g via some slicing technique for some numpy function. I will clarify this requirement in my question. – Sun Bear Jun 19 '20 at 12:36