Select file from hard drive (i.e. x = GetFile())

Looking for a default function to select a file from the users hard drive (e.g. x = GetFile()).

I’ve looked at the File and I/O packages, with no results. They seem to assume you already know where the file lives.

I’m looking for a function that opens a “Browse” window that the user can navigate and return a full path (including filename) .


Since you are looking for a “Browse” window, you are thinking of a GUI app. The GUI library that comes with Python is tkinter.

An example that might interest you is found at File Explorer in Python using Tkinter - GeeksforGeeks


There are some basic GUI file dialogs as standard:

from tkinter.filedialog import askopenfilename, asksaveasfilename

You can read up on them, and the various other dialogs provided, here: