Python Tutorial - Argparse
Вставка
- Опубліковано 16 лип 2024
- Introduction to the Argparse module in Python. Building a simple program to calculate the volume of a cylinder. Comment below if you have any questions!
Documentation:
Python 2 = docs.python.org/2/library/arg...
Python 3 = docs.python.org/3/library/arg...
Not only is he teaching python, he is also demonstrating HOW to teach. Great job, bud. Thanks a lot!
No frills. No distracting music. All content that'll get you up and running with argparse in 4:30 seconds (still understandable if played at x2 speed).
Thumbs up!
Ngl keyboard was offputting, but besides that amazing
Best video I've seen today, explains argparse in under 4 minutes! Thank you for the video!
I have spent a couple of hours reading the Python documentation and scouring Stackoverflow looking for a simple explanation of the process but they were all way to complicated. Yet this video made the part that I was interested in simply and clear.
Thank you.
Very helpful, well-structured, clear - great job! Thank you!
So well explained! Thank you!
I've been trying to learn this library on my own but it always seemed a bit confusing, but not anymore, thanks to your tutorial I finally get the basics of it!
Thank you for getting right to the point and being clear. Thank you for showing the optional arguments feature and explaining your nomenclature. Really good explanation
I never knew how it worked under the hood. Like does it internally parse the sys.argv... And I resorted to writing my own arg parsers out of laziness, because the documentation looked like -- -- -- for me, now I came across your video and tried it myself in a couple of variations I think I get it now and will start using it like everyone else. It makes sense. Thanks a lot.
Beautiful, saved me a lot of time and right to the point. Love it.
Great tutorial Johnny! Very concise and to the point. I've managed to make my first cli app with this. Thank you very much :)
Thanks Johnny! This is the best reference I have found for getting the basics and overall gist of argparse module
If every tutorial video were like this, I would be a very happy malchick!
Stupid enough, I made my own parsing module and used it in two of my projects, and then thought of searching for a more efficient way and stumbled upon this video. Thank you very much.
Thank you very much. After 8 minutes I understand how and for what I should use argparse.
Thank you, Johnny! Such a nice, simple description. You helped me a lot :D
WoW!!!! OMG!!! Best Explanation!!!!!!!! I watched several videos about argparse but non of them could explain like you did. Thank you so much!!!!!
I'm five years late to the party but still!!! Thank you for breaking this down for us. Very clear explanation. I wonder why you stopped making videos, you're a great teacher...
GREAT VIDEO! Thank you so much for such a simple and exhaustive explanation!!
Amazing tutorial, I was doing a course where they jumped straight to the code. This helped me understand what was going on.
I'm new to python and encounter argparse on one of the programs I was reading. This video clearly explains the use of argparse in a nutshell.
Bro, plz continue to make tutorials. You're way of tutoring is amazing.
I didn't know this was a thing before. That module is very useful, thanks.
Great tutorial. Argparse may be one of the greatest included libraries in python.
Exactly what I needed. Thank you for this I love you my dude
Very well explained , With argparse module,we can build industry level command line programs.Thank you for an excellent explanation.
Great tutorial. Thanks!
Thanks, you described it quite nicely and slowly for a first learner.
Excellent and easily the best explanation of argparse.
Well prepared. Thank you!!
Today when I stared reading a friend's code I was completely turned off coz I could not understand many of the components.
So I did some twitter scrolls and went back to sleep. An hour later I woke up and told myself let me first understand argparse.
...now I've learn argparse plus a personal philosophy of "Don't ever try to understand an entire project in one chunk, isolate and understand the challenging parts first" 😂
I'm still trying hard not to stop at first challenge🙂
Thanks a lot for the guide, it really helped 👍👍
Brilliant video, thank you!
you are killing it man... big big like
Right to the point, good work
Thank you man! Great video.
Hotdamn this video is easy to understand, kudos to you dude
Clear explanation. Thank you so much.
Concise and to the point! Found it better than the documentation lol.
Another useful parameter to parser.add_argument() would be default, which you missed in your video.
As with the other commenters, I found this efficient and instructive :). Thank you!
Thanks a lot for this tutorial. It helped me so much!!
Thanks! very helpful and clear. I wish you showed how to set default values to arguments, too.
Thanks for explaining 'store_true'!!!
Great Tutorial. Thank You
Good explanation, thank you so much!
Great presentation. Thanks a lot
Great video, thank a lot!
Great explanation!
This was a very helpful video. Thank you so much.
Nice job. Thanks.
Very well. Thanks dude! =D
creative way to present it. thanks a lot.
bro you saved me so much fuckin time at work with this tutorial, thanks.
thank you, it's really clear
Thank you so much. Very good informative video
you are a hero! :)
Thank you for that tutorial
great video!
very helpful. Thanks
Well explained!
very clear. thumbs up
Great video, thanks
Thanks , for the tutorial.
This was so good
Thank you
Great tutorial
thank you, it was very helpful.
PERFECT BRO!
Great job bro
thanks, it was great
BEST.INTRO.EVER.
Thank you so much~!
so good 😊
amazing bro
Thanks, that was helpful.
By default, even though you've indicated that the radius and height arguments are required, the -h help message doesn't indicate this:
>python arg3.py -h
usage: arg3.py [-h] -r -H
Calculate volume of a Cylinder
optional arguments:
-h, --help show this help message and exit
-r , --radius Radius of Cylinder
-H , --height Height of Cylinder
However, if you modify it a bit:
requiredNamed = parser.add_argument_group('required named arguments')
requiredNamed.add_argument('-r','--radius',type=int,required=True,metavar='',help='Radius of Cylinder')
requiredNamed.add_argument('-H','--height',type=int,required=True,metavar='',help='Height of Cylinder')
Then it performs as expected:
>python arg3.py -h
usage: arg3.py [-h] -r -H
Calculate volume of a Cylinder
optional arguments:
-h, --help show this help message and exit
required named arguments:
-r , --radius Radius of Cylinder
-H , --height Height of Cylinder
Thanks again!
thanks so much dude
love it
Thx helped alot
Thanks Johnny
thanks a lot!!!
newly started learning python and in one of stackoverflow posts, someone mentioned parse eval method...guess what..now I'm here and freaked out! in middle of learning object oriented programming jumped into such a topic is like shifting 3 gears at once. lol
nice demo
luv u bro..
Thank you
It was very good. I like your clear style. How about an intermediate lesson too?
Thanks!
awesome
thanks!
very nice
Nice one bud
thx form taiwan !
your dog is too cute
How do i set to display the help by default when no arguments are passed ?
I am sticking in arguments and my friends recommended it.
Could help me to how to read variables for functions from a file in argument.
For example, to execute (python my.py 123.csv parameter par.csv)
Still don't remember argparse structure and hard to work on that, hahaha
usage: 3.py [-h] radius height
3.py: error: the following arguments are required: radius, height
I'm getting this error.
can you please help me.
You need to pass in a number for the radius and the height: "python 3.py 2 4"
In the example above, the radius is 2 and the height is 4. I'm assuming your file name is "3.py", if not just change it.
@@JohnnyMetz Thank you
#it is always :
if.args.long_form_of_the_argument :
do something
# isn't it?
Correct, I don't believe you can access the arguments using the short hand notation
@@JohnnyMetz Perfect, Thank you!
no explaination and describing what the library is for etc and straight to code ? NOOOPE
Don't recommend the doc please :)
This is just what I needed! I was trying to read through someone else's code and this helped me understand what they were doing and how to do it on my own! Thanks!
This tutorial made argparse so much easier to understand, great video!
Most condensed tutorial on this topics yet it was extremely helpful especially when compared to the other ones