Skip to content

Instantly share code, notes, and snippets.

@haukex
Created Dec 10, 2018
Embed
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('sub_dir',sub_dir)
print('up_dir', up_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment