RudziankoŇ≠ RudziankoŇ≠ - 3 years ago 103
Python Question

Understanding of @gen.coroutine annotation

I know that my question looks to broad, but I hope the answer on this question will give me correct direction what to read on. I am new to Tornado framework, basically I am new to Python.
I am looking into this project:
Could you please explain me a few lines of code:

@gen.coroutine
def get_me(self):
raise gen.Return((yield self._api.get_me()))



  • What
    @gen.coroutine
    annotation is for?

  • raise
    keyword is used for exceptions, isn't it? Why we use it here?

  • Why we return everything in form of
    generator
    . Is the concept of Tornado framework to use generators. What is the reason?


Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download