Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @coroutine decorator to Coroutines #112

Open
ghost opened this issue Dec 29, 2015 · 0 comments
Open

Add @coroutine decorator to Coroutines #112

ghost opened this issue Dec 29, 2015 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 29, 2015

After reading through the presentation by David Beazley (the link at the bottom of your coroutines page), I noticed he wrote a nice decorator to help set up a coroutine. It looks like this:

def coroutine(func):
    def start(*args,**kwargs):
        cr = func(*args,**kwargs)
        cr.next()
        return cr
    return start

@coroutine
def grep(pattern):
    ...

You may want to add in reasons why people would use coroutines. For example, as part of a pipeline or filter. Slides 2-23 of David Beazley's presentation may be useful to help with examples and explanations.

I'd be interested to see what other uses for coroutines you find, especially since this is the first time I've seen them in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants