environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py
def commonprefix(items):
    """Get common prefix for completions

    Return the longest common prefix of a list of strings, but with special
    treatment of escape characters that might precede commands in IPython,
    such as %magic functions. Used in tab completion.

    For a more general function, see os.path.commonprefix
    """
    # the last item will always have the least leading % symbol
    # min / max are first/last in alphabetical order
    first_match  = ESCAPE_RE.match(min(items))
    last_match  = ESCAPE_RE.match(max(items))
    # common suffix is (common prefix of reversed items) reversed
    if first_match and last_match:
        prefix = os.path.commonprefix((first_match.group(0)[::-1], last_match.group(0)[::-1]))[::-1]
    else:
        prefix = ''

    items = [s.lstrip(ESCAPE_CHARS) for s in items]
    return prefix+os.path.commonprefix(items)
def commonprefix(items):
    """Get common prefix for completions

    Return the longest common prefix of a list of strings, but with special
    treatment of escape characters that might precede commands in IPython,
    such as %magic functions. Used in tab completion.

    For a more general function, see os.path.commonprefix
    """
    # the last item will always have the least leading % symbol
    # min / max are first/last in alphabetical order
    first_match  = ESCAPE_RE.match(min(items))
    last_match  = ESCAPE_RE.match(max(items))
    # common suffix is (common prefix of reversed items) reversed
    if first_match and last_match:
        prefix = os.path.commonprefix((first_match.group(0)[::-1], last_match.group(0)[::-1]))[::-1]
    else:
        prefix = ''

    items = [s.lstrip(ESCAPE_CHARS) for s in items]
    return prefix+os.path.commonprefix(items)
Get common prefix for completions

    Return the longest common prefix of a list of strings, but with special
    treatment of escape characters that might precede commands in IPython,
    such as %magic functions. Used in tab completion.

    For a more general function, see os.path.commonprefix