def pad(s, n, p=' ', sep='|', align='left'):
    """
    Returns a padded string.
    s = string to pad
    n = width of string to return
    sep = separator (on end of string)
    align = text alignment, "left", "center", or "right"
    """
    if align == 'left':
        return (s + p * n)[:n] + sep
    elif align == 'center':
        pos = n + len(s) / 2 - n / 2
        return (p * n + s + p * n)[pos:pos + n] + sep
    elif align == 'right':
        return (p * n + s)[-n:] + sep
