# Creating Generators

**URL:** <https://discourse.julialang.org/t/creating-generators/3962>\
**Category:** General Usage\
**Tags:** generator\
**Created:** [May 28, 2017, 12:14pm UTC](https://discourse.julialang.org/t/creating-generators/3962 "2017-05-28T12:14:17Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![o314](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/o314/32/252_2.png) [@o314](https://discourse.julialang.org/u/o314)\
**Post date:** [January 16, 2019, 2:43am UTC](https://discourse.julialang.org/t/creating-generators/3962/14 "2019-01-16T02:43:40Z")

</div>

Suppose you have this in python

```python
# aka riemann serie
def p_serie(p):
    assert(p>0)
    s = 0
    n = 1
    while True:
        s += 1.0/pow(n,p)
        yield s
        n += 1

```

then run

```python
itr = p_serie(2)
[next(itr) for _ in range(10)]

```

that output (reformatted)

```julia
[ 1.0,
  1.25,
  1.3611111111111112,
  1.4236111111111112,
  1.4636111111111112,
  1.4913888888888889,
  1.511797052154195,
  1.527422052154195,
  1.5397677311665408,
  1.5497677311665408
]

```

(1/2)

---

_[View the full topic](https://discourse.julialang.org/t/creating-generators/3962)._
