def my_func():
    with open(os.path.join(sys.prefix, 'data', 'file1.dat')) as f:
        print(next(f))
if __name__ == '__main__':
    my_func()
Determining the location of distutils data files programmatically in Python