468,483 Members | 2,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

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

If we can display the path. Can anyone please explain how?
Feb 2 '19 #1
2 1390
dwblas
626 Expert 512MB
What have you tried? What does "selected that file manually" mean?
Feb 2 '19 #2
sritaa
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.
Feb 21 '19 #3

Post your reply

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

Similar topics

3 posts views Thread by moondaddy | last post: by
2 posts views Thread by leoman730 | last post: by
2 posts views Thread by tgiles | last post: by
185 posts views Thread by jacob navia | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.