(p)
return d + head, tail
Split a pathname.

    Return tuple (head, tail) where tail is everything after the final slash.
    Either part may be empty.
Split a pathname.
Split a pathname .
def split(p):
    """Split a pathname.

    Return tuple (head, tail) where tail is everything after the final slash.
    Either part may be empty."""

    d, p = splitdrive(p)
    # set i to index beyond p's last slash
    i = len(p)
    while i and p[i-1] not in '/\\':
        i = i - 1
    head, tail = p[:i], p[i:]  # now tail has no slashes
    # remove trailing slashes from head, unless it's all slashes
    head2 = head
    while head2 and head2[-1] in '/\\':
        head2 = head2[:-1]
    head = head2 or head
    return d + head, tail
def split ( p ) : d , p = splitdrive ( p ) # set i to index beyond p's last slash i = len ( p ) while i and p [ i - 1 ] not in '/\\' : i = i - 1 head , tail = p [ : i ] , p [ i : ] # now tail has no slashes # remove trailing slashes from head, unless it's all slashes head2 = head while head2 and head2 [ - 1 ] in '/\\' : head2 = head2 [ : - 1 ] head = head2 or head return d + head , tail