def read_file(filename, alt=None):
    """
    Read the contents of filename or give an alternative result instead.
    """
    lines = None

    try:
        with open(filename, encoding='utf-8') as f:
            lines = f.read()
    except IOError:
        lines = [] if alt is None else alt
    return lines
def read_file ( filename , alt = None ) : lines = None try : with open ( filename , encoding = 'utf-8' ) as f : lines = f . read ( ) except IOError : lines = [ ] if alt is None else alt return lines
Read the contents of filename or give an alternative result instead.