10 examples of 'how to give file path in python' in Python

Every line of 'how to give file path in python' 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
129def GET_PATH(path):
130 return abspath(join(DOC_ROOT, path))
12def path(filename: str):
13 scriptdir = os.path.dirname(os.path.realpath(__file__))
14 return os.path.join(scriptdir, filename)
66def get_file_path(filename):
67 """
68 Find the book_title excel file path.
69 """
70 root_dir = d(d(abspath(__file__)))
71 root = Path(root_dir)
72 filepath = root / 'stateful_book' / filename
73 return r'{}'.format(filepath)
55def path_file(file):
56 return str(file)
36def get_path(filename):
37 return os.path.join(os.path.dirname(__file__), 'test_data', filename)
34def source(path=''):
35 '''Return a path under the source directory.'''
36 return os.path.abspath(os.path.join(sys.path[0], 'src', path))
94def fix_paths():
95 import site
96 if not hasattr(site, "USER_BASE"): return # We are running py2app
97 if os.path.basename(__file__) != 'run.py': return # Not running from source
98
99 # Fix import path: add parent directory(so that we can
100 # import vistrails.[gui|...] and remove other paths below it (we might have
101 # been started from a subdir)
102 # A better solution is probably to move run.py up a
103 # directory in the repo
104 old_dir = os.path.realpath(os.path.dirname(__file__))
105 vistrails_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
106 i = 0
107 while i < len(sys.path):
108 rpath = os.path.realpath(sys.path[i])
109 if rpath.startswith(old_dir):
110 del sys.path[i]
111 else:
112 i += 1
113 if vistrails_dir not in sys.path:
114 sys.path.insert(0, vistrails_dir)
150def get_path_with_real_case(filename):
151 from java.io import File
152 f = File(filename)
153 ret = f.getCanonicalPath()
154 if IS_PY2 and not isinstance(ret, str):
155 return ret.encode(getfilesystemencoding())
156 return ret
886def pypy_resolvedirof(s):
887 # we ignore the issue of symlinks; for tests, the executable is always
888 # interpreter/app_main.py anyway
889 import os
890 return os.path.abspath(os.path.join(s, '..'))
42def _is_py(path):
43 '''We need to make sure we are writing out Python files.'''
44 return path.split('.')[-1] == 'py'

Related snippets