It depends on the species of python.
for example the Python Molurus will attack if threatened and will fight to the death!
http://en.wikipedia.org/wiki/Python_molurus
The Python Curtis Probably wouldn't defend it self, and because of this they can be used as pets.
http://en.wikipedia.org/wiki/Python_curtus
But the most common way for a python to defend itself would be to lunge and bite. and even then it usually varies between species on whether it would, continue biting, hold on, or run away after.
A blackbrid can protect itself from danger by
The Python protects himself by eating others. He eats the others by constricting them. Constricting them enables them to breath and the victim eventually dies. To eat its prey it crushes it and gulps it up.
the reticulated python coils around it's prey until it has suffocated it entirely.
stinging
by raping its enemy
A pigeon protects itself by flying away from danger.
by running up a tree
they use there male units.
The Mallard Duck Blends into Boolrush's
it fights back
"...these snakes have a particular way of resting in the branches of trees..." -Wikipedia
hop away from enemies:)