# Python generators equivalent?

**URL:** <https://forum.elixirforum.com/t/python-generators-equivalent/2806>\
**Category:** Questions\
**Tags:** generators\
**Created:** [December 9, 2016, 10:34am UTC](https://forum.elixirforum.com/t/python-generators-equivalent/2806 "2016-12-09T10:34:08Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![smpallen99](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/smpallen99/32/1157_2.png) [@smpallen99](https://forum.elixirforum.com/u/smpallen99)\
**Post date:** [April 27, 2017, 8:58pm UTC](https://forum.elixirforum.com/t/python-generators-equivalent/2806/13 "2017-04-27T20:58:46Z")

</div>

> [@benwilson512](#):
>
> An API like
> 
> s = step(1, 2)  
> s.next() # 1  
> s.next() # 3  
> s.next() # 5
> 
> relies upon mutable state. T

Just a small note (not sure how on topic it is) about simulating functionality like this is to use a pipeline. I’ve used this approach a number of times in APIs.

> step(1,2)  
> |\> next  
> |\> next  
> |\> block(fn s → … end)  
> |\> next

---

_[View the full topic](https://forum.elixirforum.com/t/python-generators-equivalent/2806)._
