Invalid Path when getting Notebook Path

Steve_Harrison
New Contributor III

The undocumented feature to get a notebook path as is great but it does not actually return a valid path that can be used in python, e.g.:

from pathlib import Path

print(Path(dbutils.notebook.entry_point.getDbutils().notebook().getContext().notebookPath().get()).exists())

Always returns False. Is there a method of getting the actual path of a notebook?

The above suffers from two problems:

  1. It appears to strip off the /Workspace from the start of the path
  2. It removes the suffix from the path

2 is not so much of an issue but the first one is a royal pain.