# 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:** 3

<div class="post-metadata">

**Author:** ![orestis](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/orestis/32/1949_2.png) [@orestis](https://forum.elixirforum.com/u/orestis)\
**Post date:** [December 9, 2016, 11:38am UTC](https://forum.elixirforum.com/t/python-generators-equivalent/2806/3 "2016-12-09T11:38:16Z")

</div>

Thanks for the link.

Re the magic, would you expect:

```elixir
s = Stream.unfold(1, fn(x) -> 
  receive do
    :next -> IO.puts "hi";{x, x+2} 
  end
end)
Stream.run(s)

```

… to loop forever? It has similar semantics. I think I could probably implement this with the available tools, yes 🙂

---

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