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!
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 !!
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.
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.
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😁
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
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
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...
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!
Thank you!
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 !!
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.
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.
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😁
Dave The Great!❤❤
Thank you!
Does "description" refer to the entire function?
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
This is a good tutorial.
you were able to get your code to work? It's not working for me.
Thanks you, sir.
You're welcome!
Thank you!
Welcome!
My code works fine without the ".title" in line 33 and 34. Why do you include that?
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
[Errno 2] No such file or directory ??
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...