No bro.. this is just specifically for notebooks... Do you know something for .py files?

Moreover the code above doesn't even work for notebooks .. The answer I got with your code is below

/Users/krishna@company.com/Project_Folder/test_nb.ipynb

while I expected the path to be where I created the notebook.. (below)

"/dbfs/FileStore/shared_uploads/krishna@company.com/Project_Folder/test_nb.ipynb"