Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Created June 5, 2015 10:19
Show Gist options
  • Select an option

  • Save awesomebytes/04a616c6c7c45dab79e3 to your computer and use it in GitHub Desktop.

Select an option

Save awesomebytes/04a616c6c7c45dab79e3 to your computer and use it in GitHub Desktop.
def msg_to_list(message):
"""
Given a message, e.g.: Vector3(x=0.0, y=0.0, z=0.0)
returns the list of it's slots, e.g.: [0.0, 0.0, 0.0]
:param message: some message that we want it's slots into a list
:return: the slots as a list
"""
output_list = []
for slot in message.__slots__:
output_list.append(message.__getattribute__(slot))
return output_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment