I want to replace file_location = os.path.abspath(os.path.dirname(__file__))
with pathlib
to get the aboslute path of the file without the filename
with using directorypath = pathlib.Path(__file__).resolve()
gives me the absolute path + the filename
how can I get the absolute path without the filename ?
Asked
Active
Viewed 4,254 times
6

Sator
- 636
- 4
- 13
- 34
1 Answers
9
You can use '.parent': directorypath = pathlib.Path(__file__).resolve().parent
Path.parent

Noctis Skytower
- 21,433
- 16
- 79
- 117

Jay.Cee.
- 106
- 1
- 2