BTW, you can access the
rotation_degrees properties directly, you don't have to use the
get_ method. As a bonus, autocomplete works with the properties, but not the getter/setter.
To keep your rotation in the range, you can use the modulus operator, which is
fmod() for floating points:
rotation_degrees = fmod(rotation_degrees, 360)
rotation = fmod(rotation, 2 * PI)