次のコードで取得できる。

import os

os.path.dirname(**file**)