If I want the path of the current module, I\'ll use __file__.
__file__
Now let\'s say I want a function to return that. I can\'t do:
def get_path
This is how I would do it:
import sys def get_path(): namespace = sys._getframe(1).f_globals # caller's globals return namespace.get('__file__')