10 examples of 'os.path.dirname(__file__)' in Python

Every line of 'os.path.dirname(__file__)' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
143def get_path():
144 if getattr(sys, 'frozen', False):
145 return os.path.dirname(sys.executable)
146 else:
147 return os.path.abspath(os.path.dirname(sys.argv[0]))
12def path(filename: str):
13 scriptdir = os.path.dirname(os.path.realpath(__file__))
14 return os.path.join(scriptdir, filename)
36def get_path(filename):
37 return os.path.join(os.path.dirname(__file__), 'test_data', filename)
151def get_parent(path):
152 return os.path.dirname(path)
57def get_data_files_path():
58 """Get a direct path to the data files colocated with the script.
59
60 Returns:
61 The directory where files specified in data attribute of py_test
62 and py_binary are stored.
63 """
64 return _os.path.dirname(_inspect.getfile(_sys._getframe(1)))
9def get_path(dir, filename):
10 return os.path.join(
11 os.path.dirname(__file__),
12 dir, filename
13 )
26def _get_script_path():
27 """Get directory path of current script"""
28 script_filename = inspect.getframeinfo(inspect.currentframe()).filename
29 script_path = os.path.dirname(os.path.abspath(script_filename))
30
31 return script_path
206def get_original_dir():
207 return ORIGINAL_DIR
74def _HERE(*args):
75 h = os.path.dirname(os.path.realpath(__file__))
76 return os.path.abspath(os.path.join(h, *args))
129def GET_PATH(path):
130 return abspath(join(DOC_ROOT, path))

Related snippets