Question: I am trying to create a generator that prints the next number on the list. This is a racket version:

```
  (require racket/generator)

  (define my-gen
    (generator
     (_)
     (for ([x (list 1 2 3))])
       (yield x)))

```

)

How it should work: 

```
(my-gen) -> 1
(my-gen) -> 2

```

I also want to be able to use the function directly without having to initialize it at a specific point, so having the generator be the function that actually returns the result, as opposed to something like this:

```
l = [1, 2, 3]
def myGen():
    for element in l:
        yield element

g = myGen()
print(next(g))

```

What is the best way to go about this in python?

Answer: 
Using [`functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial):

```
>>> import functools
>>> l = [1, 2, 3]
>>> my_gen = functools.partial(next, iter(l))
>>> my_gen()
1
>>> my_gen()
2
>>> my_gen()
3
>>> my_gen()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration

```
Is this what you are looking for?

```
number = 1
while(number<500 +1):
    print('(my-gen) ->', number)
    number +=1

```