Using __dict__ in MUSE Python Code
Question:
How can I use the __dict__ attribute in MUSE Python Code?
Answer:
The __dict__ attribute (that's two underscores before and after the dict) allows you to print out all of the variables and values associated with an event in Python code. Whether the event is a watch or a listen, the __dict__ attribute will output all the information contained within that event. The information is displayed as a Python dictionary of key/value pairs for any given event.
The easiest way to use the __dict__ attribute is to utilize a print statement in the event callback function. For example:

When using this with a __dict__ on a button event you receive a print out like this:

The __dict__ attribute contains entries for many variables including:
- source - The object that triggered the event
- id - The ID number of the originating event
- path - The path the event originated from
- device - The device the event originated from
- value - The value of the parameter that triggered the event
- newValue - The new value of that parameter
- oldValue - The previous value of the parameter
- normalized - The normalized value of the parameter
The reason for the two separate events is because an event is triggered on both the push and release of button events. That's why you see both True and False values in the image.
Note: Many events share keys such as source, id, and path, but events change from device to device or parameter to parameter. If you are ever wondering what is actually being returned to the MUSE controller for any given event, utilize the __dict__ attribute printout.