def dist_between(h,seg1,seg2):
    """
    Calculates the distance between two segments. I stole this function from
    a post by Michael Hines on the NEURON forum
    (www.neuron.yale.edu/phpbb/viewtopic.php?f=2&t=2114)
    """
    h.distance(0, seg1.x, sec=seg1.sec)
    return h.distance(seg2.x, sec=seg2.sec)