Click here to Skip to main content
14,486,704 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to understand how Client.event works in This is the source code for the event method.
def event(self, coro):
    # Validation we don't need to worry about
    setattr(self, coro.__name__, coro)
    return coro

According to what I understand, a coroutine is passed into the event function and an attribute of the object is created with name same as the name of the coroutine and the value equal to the output of coroutine. What I don't understand is that what is the object we are talking about?

Here is the source code for and I am unable to figure out where an object is being created. Please help.

Also, since a coroutine is taken as an argument, does it mean that only function which are preceded by async can be passed?

What I have tried:

I tried looking for a declaration of an object of the class client in the source code but could not find one.
Updated 23-Mar-20 8:09am
Richard MacCutchan 24-Mar-20 5:50am
The source of has over 3000 lines. No one is going to read all that. You need to study the documentation for the package to see how to use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100