'Combinations of Generators in Python

If I have a generator, and I use itertools.combinations(generator, n) on it, the generator I created will be empty. Is it possible to keep the generator as it is?

Example:

g = (i for i in range(100))
print(list(g))
combinations = itertools.combinations(g, 5)
print(list(g)

Output:

[0, 1, 2, 3, 4, 5,..., 97, 98, 99]
[] # i want this to be same as above


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source