Python Command Line Arguments tutorial for Beginners

  Рет қаралды 9,899

Dave Gray

Dave Gray

Күн бұрын

Пікірлер: 21
@PeranMe
@PeranMe Жыл бұрын
I have to admit that I felt a little sceptical when someone recommended I use the argparse module when all I was looking for was if Python exposes arguments like in a list or something. But 5 minutes later, after skimming the documentation, boy, was I grateful that whoever it was that suggested argparse had done so! You’re definitely right to be introducing it this early in your Python series; it’s a great example of why your FIRST instinct when looking to solve a problem in Python should be to google for a module. As always a great video, thanks!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@ayushman1325
@ayushman1325 Жыл бұрын
Dave The Great!❤❤
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Thank you!
@deepatterson1894
@deepatterson1894 9 ай бұрын
For some reason I keep getting : can't open file error message, I've tried everything even copying your lesson running it directly I save it in the LESSON 15 directory. It seems when I have to use commands in the terminal is when I run into problems. One thing I notice is that you always have a $ that comes before the py but mine doesn't the $. Everything else has been great, It must be something changed with Python since you did these lessons.
@deepatterson1894
@deepatterson1894 9 ай бұрын
Figured out what I did wrong. The folder DAVE GREY or whatever name for folder chosen to put lessons in. Example in my case I used DAVE GREY. It needs the underscore in-between first and last name DAVE_GREY. Simple thing I thought I even did this at one point but now works! Just incase anyone else has the same or similar issue.
@ahmad-murery
@ahmad-murery Жыл бұрын
Thanks for the shoutout Dave! I really appreciate that. Now, we can go further and localize this game by expanding the technique used in the hello_person example, msg = { "English": { "player choice": " {name}, please enter... 1 for Rock, 2 for Paper, or 3 for Scissors: ", "choice confirm": "{name}, please enter 1, 2, or 3", }, "German": { "player choice": " {name}, bitte geben Sie ein... 1 für Stein, 2 für Papier oder 3 für Schere: ", "choice confirm": "{name}, bitte geben Sie 1, 2 oder 3 ein.", } } lang = "German" data = {"name": "Ahmad"} print(msg[lang]["player choice"].format(**data)) # or maybe use # print(msg[lang]["player choice"].format(name = 'Ahmad')) Maybe it's better to save language dictionary to a separate module per language and then import necessary one into the main game file, this will allow contributors to add more languages (and will keep the game small, clean and easier to update independently) Google translate was used for German messages, so please forgive me for any mistakes😁
@alhabib_o
@alhabib_o 4 ай бұрын
Shouldn't we remove the 'required=True' from the add_argumetn( ) ? but this way we can run from anywhere not just from the terminal window..... And, why do I need to mark the name parameter as 'nonlocal' if I'm not going to modify it? Thank you so much, Dave for this amazing tutorial !!
@herway1875
@herway1875 9 ай бұрын
This is a good tutorial.
@deepatterson1894
@deepatterson1894 9 ай бұрын
you were able to get your code to work? It's not working for me.
@johnaweiss
@johnaweiss 11 ай бұрын
Does "description" refer to the entire function?
@markyuuki5736
@markyuuki5736 5 ай бұрын
Thank you for your videos. I am recently dealing with this error: File "", line 1 py rps8.py -n "Dave" ^^^^ SyntaxError: invalid syntax Can you help me in fixing it? Thank you in advance
@utinthein7274
@utinthein7274 Жыл бұрын
Thanks you, sir.
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@dimabrinza
@dimabrinza Жыл бұрын
Thank you!
@DaveGrayTeachesCode
@DaveGrayTeachesCode Жыл бұрын
Welcome!
@quarkorion
@quarkorion 8 ай бұрын
My code works fine without the ".title" in line 33 and 34. Why do you include that?
@mrsengeel
@mrsengeel 7 ай бұрын
to convert the first character of a word to upper case while the rest of the character will be in lower case For example: friends = "hello world" find = friends.title() print(find) #output will be "Hello World" hope this helps
@quinnjin2
@quinnjin2 2 ай бұрын
[Errno 2] No such file or directory ??
@quinnjin2
@quinnjin2 2 ай бұрын
so I tried to "CD ~/" (Mac OS) to the directory to run the file... didn't work... so then I quit out, saved everything, and just drugged this lesson folder on to the visual studio file, opened terminal typed "python3 hello_person.py" and it worked, listed "usages:" and left me with "MacBook-Pro 15 COMMAND LINE ARRGUMENTS %" and a cursor...
Python Challenges for Beginners with Solutions
15:52
Dave Gray
Рет қаралды 7 М.
Python File Handling for Beginners
22:40
Dave Gray
Рет қаралды 23 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,2 МЛН
Chapter 7.Generics | Typescript Masterclass | Code With Soumyajeet
1:00:31
Code With Soumyajeet
Рет қаралды 114
Python Modules for Beginners
18:03
Dave Gray
Рет қаралды 12 М.
Python Exception Handling Tutorial for Beginners
12:16
Dave Gray
Рет қаралды 7 М.
Python Tutorial for Beginners with VS Code 🐍
13:56
Dave Gray
Рет қаралды 333 М.
Recursion for Python Beginners with Recursive Function Examples
17:54
Create A Python API in 12 Minutes
12:05
Tech With Tim
Рет қаралды 709 М.