def read_pyfile(filename):
 with open(filename, 'rb') as pyfile:
  encoding = tokenize.detect_encoding(pyfile.readline)[0]
 with open(filename, 'r', encoding=encoding) as pyfile:
  source = pyfile.read()
 return source

def read_pyfile ( filename ) : with open ( filename , 'rb' ) as pyfile : encoding = tokenize . detect_encoding ( pyfile . readline ) [ 0 ] with open ( filename , 'r' , encoding = encoding ) as pyfile : source = pyfile . read ( ) return source
read and return the contents of a python source file .