Set physics type in bge using python?
It's easy to turn a rigid body static and back again. Start with a rigid body, and then you can suspend/restore the dynamics:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
own.suspendDynamics()
#OR
own.restoreDynamics()




A slightly more hacky way to turn a rigid body static is to set it's mass to infinite (ie no force will have an effect).

import bge

cont = bge.logic.getCurrentController()
own = cont.owner
own.mass = float('inf')


To make it rigid body again, set it's mass back to a proper number



To make an object dynamic is hard as BGE doesn't have access to the inertia tensor/radius of gyration. Even setting the angular velocity cap to 0.0 doesn't work. I guess you'd have to, every frame, set it's angular velocity to zero and restore it's orientation.

(untested code):

import bge

own = bge.logic.getCurrentController().owner
if 'ori' not in own:
    own['ori'] = own.worldOrientation.copy()
own.worldOrientation = own['ori']
own.worldAngularVelocity = [0.0, 0.0, 0.0]