The on_connect() and on_disconnect() callback handlers are examples of the full life cycle that is available using the Paho client class. We will see how to instantiate a Paho client instance and register these callbacks later when we cover the init_mqtt() method.
The parameters of interest to on_connect() at line (7) in the following code block are client, which is a reference to the Paho client class, and result_code, which is an integer describing the connection result. We see result_code used at line (8) to test the success of the connection. Notice the connack_string() method, which is used for a connection failure to translate result_code into a human-readable string.
When we speak of the MQTT client and see the client parameter at line (7) in the following code block, remember this is our Python code's client connection to the broker, NOT a reference to a client...