Load file from same folder as Python 3.x script inside package

You can use importlib.resources.read_text in order to read a file that's located relative to a package:

from importlib.resources import read_text

data = read_text('mypkg.foo', 'mydata.txt')