Skip to content

Instantly share code, notes, and snippets.

Created Dec 10, 2018
What would you like to do?
Python: pathnames relative to current python file
import os
my_dir = os.path.dirname(os.path.abspath(__file__))
sub_dir = os.path.join(my_dir, 'test');
up_dir = os.path.join(os.path.split(my_dir)[0], 'other');
from conf import *
print('my_dir', my_dir)
print('up_dir', up_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment