here = lambda x: os.path.abspath(os.path.join(os.path.dirname(__file__), x))
DATA_DIR = here('datadir')
pathjoin = os.path.join
for fn in os.listdir(DATA_DIR):
    f = open(pathjoin(DATA_DIR, fn))
Python - how to refer to relative paths of resources when working with code repository