I am working on a script where I ask the user to enter paths of certain files or directories.
I could use path=raw_input("Enter path: ") , but is this the right way (or the only way)?
I have been trying to find an alternative to this for a while now, and haven't been able to figure out a solution. In an ideal situation, I wish to use TAB to auto-fill the path entered by the user, like you do in console.
Any leads will be appreciated. Cheers. :)
Sai Kishore Komanduri
Engineering an eGovernance Product | Hashnode Alumnus | I love pixel art
I had to do something similar quite a while ago. You could use Python's
globmodule for gathering all the pathnames that match user's input pattern; andreadlinemodule to facilitate the autocompletion.Here's a handy gist with an example implementation:
Hope this helps! :)