path()¶
- audeer.path(path, *paths, follow_symlink=False)[source]¶
Expand and normalize to absolute path.
It uses
os.path.realpath()andos.path.expanduser()to ensure an absolute path without..or~, and independent of the path separator of the operating system. Iffollow_symlinkisFalse, the fasteros.path.abspath()is used instead ofos.path.realpath().- Parameters
- Return type
- Returns
(joined and) expanded path
Examples
>>> home = audeer.path("~") >>> folder = audeer.path("~/path/.././path") >>> folder[len(home) + 1 :] 'path' >>> file = audeer.path("~/path/.././path", "./file.txt") >>> file[len(home) + 1 :] 'path/file.txt' >>> file = audeer.touch("file.txt") >>> link = audeer.path("link.txt") >>> os.symlink(file, link) >>> os.path.basename(audeer.path(link)) 'link.txt' >>> os.path.basename(audeer.path(link, follow_symlink=True)) 'file.txt'