goless.readthedocs.io - goless: Go-style Python — goless 0.6.0 documentation

Example domain paragraphs

The goless library provides Go programming language semantics built on top of gevent , PyPy , or Stackless Python .

For an example of what goless can do, here is the Go program at https://gobyexample.com/select reimplemented with goless :

c1 = goless . chan () c2 = goless . chan () def func1 (): time . sleep ( 1 ) c1 . send ( 'one' ) goless . go ( func1 ) def func2 (): time . sleep ( 2 ) c2 . send ( 'two' ) goless . go ( func2 ) for i in range ( 2 ): case , val = goless . select ([ goless . rcase ( c1 ), goless . rcase ( c2 )]) print ( val ) It is surely a testament to Go’s style that it isn’t much less Python code than Go code, but I quite like this. Don’t you?