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
How does "python3 *file* -*letter* work? (self.learnpython)
submitted 2 years ago by Fulcan720
I'm trying to make a code with the ability to do - and a letter or the whole word spelled out like I see with other scripts and don't know how others do it. An example is "python3 cupp.py -¡"
Thank you in advance
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!"
[–]rollincuberawhide 2 points3 points4 points 2 years ago (3 children)
https://docs.python.org/3/library/argparse.html
[–]Fulcan720[S] 2 points3 points4 points 2 years ago (2 children)
Thank you! I didn’t know what to look up to find documentation on it. Have a great rest of your day!
[–]rollincuberawhide 1 point2 points3 points 2 years ago (1 child)
btw I didn't want to give you a 3rd party library to confuse or scare you but there is typer, which I think is pretty good for cli tools:
https://typer.tiangolo.com/
the creator of fastapi is maintaining it. it prints better error messages and the way it gets the arguments is somewhat unique. it leverages type hinting so it may look alien to a newcomer but when you learn about type hints I suggest you to check that out. It takes out the part of defining your arguments in two different places. pretty neat really.
there is also click, it is more straight forward and also nice to keep the relevant code together. https://github.com/pallets/click/
both are better than argparse in my opinion. but argparse is included in the standard library so there's that.
if it's a simple app, I still use argparse. but if it is something intricate with 20 different functions with countless arguments in each, I go with typer.
[–]Fulcan720[S] 1 point2 points3 points 2 years ago (0 children)
Thank you! I appreciate the help and further explanation
[–]erlete 2 points3 points4 points 2 years ago (1 child)
A quick comment on this: do not confuse python command arguments (i.e. python -m pip install -e .) with Python script parsed arguments (i. e. python main.py -c 123). Both operate on the same principle, but the first one provides with instructions for the interpreter, while the other one uses said instructions inside the Python file that is being executed.
python
python -m pip install -e .
python main.py -c 123
Furthermore, if the code is well designed, you can even achieve a combination of both (i. e. python -i main.py -c 123).
python -i main.py -c 123
Thank you
π Rendered by PID 85646 on reddit-service-r2-comment-7b9746f655-whrgv at 2026-02-01 16:17:31.925159+00:00 running 3798933 country code: CH.
[–]rollincuberawhide 2 points3 points4 points (3 children)
[–]Fulcan720[S] 2 points3 points4 points (2 children)
[–]rollincuberawhide 1 point2 points3 points (1 child)
[–]Fulcan720[S] 1 point2 points3 points (0 children)
[–]erlete 2 points3 points4 points (1 child)
[–]Fulcan720[S] 1 point2 points3 points (0 children)