PyTox icon indicating copy to clipboard operation
PyTox copied to clipboard

Magic name callbacks -> decorators

Open dubslow opened this issue 10 years ago • 0 comments

In my opinion, magically named callbacks are A Bad Idea™. Instead, it would by more pythonic IMO to use decorators to satisfy a callback, e.g.

def MuhTox(Tox):

    @OnFriendMessage
    def muh_echo(self, friend_num, msg):
        self.send_message(friend_num, msg)

(Python itself does have magic names, but they are all dundered. I still think that in this case, decorators are more pythonic than dundered names anyways.)

dubslow avatar Jan 27 '15 17:01 dubslow