Posted By

jarnaldich on 06/22/11


path relative

Versions (?)

Get an absolute from a path relative to the current file

 / Published in: Python

Sometimes (ex. django templates section at, a function expects an absolute path, but it's more practical when developing to refer it to the current file position in our code base. The rel function does exactly that.

  1. import os
  2. def rel(*x):
  3. return os.path.normcase(os.path.join(os.path.dirname(__file__), *x))

Report this snippet  

You need to login to post a comment.