(name, extra_chars='')
Remove any invalid characters for file name.
Remove any invalid characters for file name.
Remove any invalid characters for file name .
def format_name(name, extra_chars=''):
    """Remove any invalid characters for file name."""
    try:
        return sub('[^A-Za-z0-9{}]+'.format(extra_chars), '', name).lower()
    except TypeError:
        if not isinstance(name, str):
            return format_name(str(name), extra_chars=extra_chars)
        raise
def format_name ( name , extra_chars = '' ) : try : return sub ( '[^A-Za-z0-9{}]+' . format ( extra_chars ) , '' , name ) . lower ( ) except TypeError : if not isinstance ( name , str ) : return format_name ( str ( name ) , extra_chars = extra_chars ) raise