Skip to content

Instantly share code, notes, and snippets.

@zeekay
Last active August 29, 2015 13:55
Show Gist options
  • Save zeekay/8705007 to your computer and use it in GitHub Desktop.
Save zeekay/8705007 to your computer and use it in GitHub Desktop.
Python vs Go round 2.
package main
import "fmt"
func ping(c chan string) {
fmt.Println("starting ping")
for {
c <- "ping"
pong := <-c
fmt.Println(pong)
}
}
func pong(c chan string) {
fmt.Println("starting pong")
for {
ping := <-c
fmt.Println(ping)
c <- "pong"
}
}
func main() {
c := make(chan string)
go ping(c)
go pong(c)
// Block forever
select {}
}
def ping():
while True:
yield "ping"
pong = yield
print pong
def pong():
while True:
ping = yield
print ping
yield "pong"
# ok but how to route them around? no channels :(
@gf0842wf
Copy link

the second : dispatcher is a good idea. http://pydispatcher.sourceforge.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment