>>> strip_optional_prefix('abcdef', 'abc')
    'def'
    >>> strip_optional_prefix('abcdef', '123')
    'abcdef'
    >>> strip_optional_prefix('abcdef', '123', PrintingLogger())
    String starts with 'abc', not '123'
    'abcdef'

def strip_optional_prefix(string, prefix, log=None):
    """
    >>> strip_optional_prefix('abcdef', 'abc')
    'def'
    >>> strip_optional_prefix('abcdef', '123')
    'abcdef'
    >>> strip_optional_prefix('abcdef', '123', PrintingLogger())
    String starts with 'abc', not '123'
    'abcdef'
    """
    if string.startswith(prefix):
        return string[len(prefix):]
    if log:
        log.warn('String starts with %r, not %r', string[:len(prefix)], prefix)
    return string