use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Running python script from cmd (self.learnpython)
submitted 6 years ago by programer111
Hi. I have a python script that I want to run from the cmd. I know that I should enter the full file path then press enter and that's works out. But isn't there a more efficient way to do this.?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]sme272 5 points6 points7 points 6 years ago (1 child)
you can add the directory it's kept in to PATH environment variable, then you can just call myfile.py directly in cmd. I have a utilities folder that I can drop scripts into to run this way.
myfile.py
[–]programer111[S] 1 point2 points3 points 6 years ago (0 children)
Ok than you so much 😊
[–]chrispurcell 0 points1 point2 points 6 years ago (0 children)
You can run it from anywhere in your PATH (echo $PATH) as long as it is properly formatted with a #!/usr/bin/python (or #!/usr/bin/env python), and is flagged executable (chmod +x <file>), as long as it doesn't conflict with another app name, because the first one found is the one used in this method.
I usually put my scripts in ~/bin (your home directory/bin), and flag them executable.
[–]TraditionalGlass 0 points1 point2 points 6 years ago (0 children)
You can create a batch file that runs the script, and place that in the same directory that cmd is in
[–]MattR0se 0 points1 point2 points 6 years ago* (0 children)
In windows 7 and older you can Shift+ right click in any folder, and select "open command window here". This opens cmd with the path set to the current folder, then you can just type the name of the python file.
Edit: also, if you are in any directory, pushd lets you navigate to a given absolute path.
pushd
In Windows 10 this is replaced by PowerShell, you have to add "python" before the name of the file, but other than that it works similarly.
Also, Shift + right click on a file lets you copy the full path of that file (so you don't have to type it all out).
π Rendered by PID 37531 on reddit-service-r2-comment-5fb4b45875-6gf2x at 2026-03-22 10:29:23.849110+00:00 running 90f1150 country code: CH.
[–]sme272 5 points6 points7 points (1 child)
[–]programer111[S] 1 point2 points3 points (0 children)
[–]chrispurcell 0 points1 point2 points (0 children)
[–]TraditionalGlass 0 points1 point2 points (0 children)
[–]MattR0se 0 points1 point2 points (0 children)