user8442424
user8442424

Reputation:

How do I call a Python function when another function has been called?

I am writing a Python python program that includes two functions: bot.say() and message_sent(). I want message_sent() to be called every time bot.say() is called, in an efficient manner. How would this be achieved?

Upvotes: 0

Views: 44

Answers (1)

Peter
Peter

Reputation: 3495

One simple way would be make a function call both of them, and use that in your code instead of bot.say(). From the two examples you provided, assuming there's nothing else to pass in, you could do something like below.

def bot_message(bot):
    bot.say()
    message_sent()

Upvotes: 1

Related Questions