Skip to content

Instantly share code, notes, and snippets.

@polmuz
Created February 11, 2016 18:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polmuz/cd882b1267e96a60a267 to your computer and use it in GitHub Desktop.
Save polmuz/cd882b1267e96a60a267 to your computer and use it in GitHub Desktop.
Simple python function to build paths relative to the current file
# source http://code.tutsplus.com/articles/diving-into-django--net-2969
import os
def rel(*l):
"""
Create paths relative to this file
e.g.
rel('tmp', 'bla.txt') -> '<this file dir>/tmp/bla.txt'
"""
return os.path.join(os.path.abspath(os.path.dirname(__file__)), *l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment