Animate a whip

How do I animate a whip wrapping around an object?