How do I comb hair in python?
The python API for combing hair is not very complete.  You can adjust the control points for individual hairs using code like this:

def comb1(obj):
    ps = obj.particle_systems[0]
    dx =10
    dy = 10
    for i in range(dx):
        for j in range(dy):
            idx = i*10+j
            particle = ps.particles[idx]
            dz = len(particle.hair_keys)
            for k in range(dz): 
                x =  k*0.1*i
                r = math.pi*dy/(1+j+1)
                theta = k /r
                y =  (1-math.cos(theta))*r
                z = math.sin(theta)*r
                particle.hair_keys[k].co_local = (x,y,z)


That is an intermediate result from my research.  It successfully sets the control points for the parent hairs.


It does not update the UI.  You have to toggle between Particle Edit and Object modes for the UI to refresh.
You can not really adjust the position of the root using python.  While there is a "location" property on the python particle object, it is just a computed value.  The real value is a barycentric coordinate "fuv" for the face indexed by "num", and both are only accessible from C (or a version of blender with hacked dna).  Using "displaced" values in co_local works for the parent hairs, but child hairs will not be interpolated correctly.


As of blender 2.71 the python API for editing particle systems has some shortcomings.  A chat with some folks in #blendercoders came up with a reference to some past work on editing the point cache, although the previous work was with the cloth sim and significant work would have to be done to adapt it for the particle cache (and it requires that you enable Hair Dynamics).