def read_text_file(filename, encoding='utf-8'):
    '\n    Reads a file under python3 with encoding (default UTF-8).\n    Also works under python2, without encoding.\n    Uses the EAFP (https://docs.python.org/2/glossary.html#term-eafp)\n    principle.\n    '
    try:
        with open(filename, 'r', encoding) as f:
            r = f.read()
    except TypeError:
        with open(filename, 'r') as f:
            r = f.read()
    return r
Reads a file under python3 with encoding (default UTF-8).
Also works under python2, without encoding.
Uses the EAFP (https://docs.python.org/2/glossary.html#term-eafp)
principle.
def read_text_file(filename, encoding='utf-8'):
    '\n    Reads a file under python3 with encoding (default UTF-8).\n    Also works under python2, without encoding.\n    Uses the EAFP (https://docs.python.org/2/glossary.html#term-eafp)\n    principle.\n    '
    try:
        with open(filename, 'r', encoding) as f:
            r = f.read()
    except TypeError:
        with open(filename, 'r') as f:
            r = f.read()
    return r