By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Can we display the path of a file in python console if we selected that file manually

P: 1
If we can display the path. Can anyone please explain how?
Feb 2 '19 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 606
What have you tried? What does "selected that file manually" mean?
Feb 2 '19 #2

P: 5
Sure you can. The beauty of the command line is that it does exactly what you say to do. If you say

python my_file.txt
The file my_file.txt will be executed by the Python interpreter. On GUI systems, file types determine what happens when you double-click a file, or maybe what is suggested to you to open in a program (Microsoft Word greys out anything that isn't a .doc or .docx for example).

But on the command line, you give a command and arguments. The first unnamed (meaning without a flag before it) argument to the Python interpreter is the file you want to execute. It doesn't need to have a .py on the end because you're telling the Python interpreter what file to execute. You're not opening a program and then browsing for a file, or double-clicking a file so that your OS has to figure out what to do with it.
4 Weeks Ago #3

Post your reply

Sign in to post your reply or Sign up for a free account.