Getting object's rotation angles and exporting them ?

Since I’ve been advised to post on Blender Stack Exchange lately, I posted there, but I wonder if I can get help here as well.

Currently I have add-on that gets rotations from an object, converts angles into a matrix and saves it in a particular format into a text file.
This is what code for that looks like:

rot = tuple(chain(*obj.matrix_world.to_3x3().normalized().transposed()))

dump += ['"rotation" "{}"'.format(" ".join(str(r) for r in rot)),]

self.write(self.filepath, "

I also need to have Euler angles written after “rotation” in the following format:
“angles” “Y Z X”
Where Y, Z and X are angles in degrees.
How would I do that, following analogy with rotation matrix ? Thanks.

I’d use the order of the euler_angle to order.

>>> r = C.object.matrix_world.to_euler('YZX')
>>> r
Euler((0.0, 0.0, 0.4363323450088501), 'YZX')

>>> [degrees(getattr(r, c)) for c in r.order.lower()]
[0.0, 25.00000183405324, 0.0]


Nice way to change order!

What I noticed with different initial orders: the angles will be slightly different, not sure if it’s a floating point number precision problem.