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...

КОМЕНТАРІ • 139

  • @prateekyadav7679
    @prateekyadav7679 2 роки тому +16

    Not only is he teaching python, he is also demonstrating HOW to teach. Great job, bud. Thanks a lot!

  • @IsaacC20
    @IsaacC20 6 років тому +107

    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!

    • @Muhammadalafifi
      @Muhammadalafifi Рік тому

      Ngl keyboard was offputting, but besides that amazing

  • @harbaapkabaap2040
    @harbaapkabaap2040 2 роки тому +2

    Best video I've seen today, explains argparse in under 4 minutes! Thank you for the video!

  • @continental_drift
    @continental_drift 5 років тому +15

    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.

  • @nadiiaradionenko8793
    @nadiiaradionenko8793 4 роки тому +7

    Very helpful, well-structured, clear - great job! Thank you!

  • @alinasansevich9182
    @alinasansevich9182 3 роки тому +3

    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!

  • @tilen873
    @tilen873 3 роки тому +1

    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

  • @samre3006
    @samre3006 3 роки тому +6

    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.

  • @g38ra
    @g38ra 4 роки тому +6

    Beautiful, saved me a lot of time and right to the point. Love it.

  • @DiegoTrapero
    @DiegoTrapero 5 років тому +4

    Great tutorial Johnny! Very concise and to the point. I've managed to make my first cli app with this. Thank you very much :)

  • @wlcrutch
    @wlcrutch 2 роки тому

    Thanks Johnny! This is the best reference I have found for getting the basics and overall gist of argparse module

  • @quidquopro1185
    @quidquopro1185 2 роки тому

    If every tutorial video were like this, I would be a very happy malchick!

  • @shinej11
    @shinej11 2 роки тому

    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.

  • @RuslanSkiraUkraine
    @RuslanSkiraUkraine 2 роки тому

    Thank you very much. After 8 minutes I understand how and for what I should use argparse.

  • @anastasiakratschmer9560
    @anastasiakratschmer9560 Рік тому +2

    Thank you, Johnny! Such a nice, simple description. You helped me a lot :D

  • @Owlzon
    @Owlzon 2 роки тому

    WoW!!!! OMG!!! Best Explanation!!!!!!!! I watched several videos about argparse but non of them could explain like you did. Thank you so much!!!!!

  • @jay_agara
    @jay_agara Рік тому

    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...

  • @user-tj4ut8ox9r
    @user-tj4ut8ox9r 2 роки тому +1

    GREAT VIDEO! Thank you so much for such a simple and exhaustive explanation!!

  • @VasudhaJoshi
    @VasudhaJoshi 2 роки тому

    Amazing tutorial, I was doing a course where they jumped straight to the code. This helped me understand what was going on.

  • @celltrix1
    @celltrix1 2 роки тому

    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.

  • @gyangaha109
    @gyangaha109 2 роки тому +1

    Bro, plz continue to make tutorials. You're way of tutoring is amazing.

  • @0_-
    @0_- 3 роки тому

    I didn't know this was a thing before. That module is very useful, thanks.

  • @BenStoneking
    @BenStoneking 3 роки тому

    Great tutorial. Argparse may be one of the greatest included libraries in python.

  • @PoPeyePro
    @PoPeyePro 3 роки тому

    Exactly what I needed. Thank you for this I love you my dude

  • @anirvansen6591
    @anirvansen6591 4 роки тому

    Very well explained , With argparse module,we can build industry level command line programs.Thank you for an excellent explanation.

  • @passworduser
    @passworduser 6 років тому +2

    Great tutorial. Thanks!

  • @sagnikroy6405
    @sagnikroy6405 2 роки тому

    Thanks, you described it quite nicely and slowly for a first learner.

  • @tonydavidson8260
    @tonydavidson8260 8 місяців тому

    Excellent and easily the best explanation of argparse.

  • @nalloastro6353
    @nalloastro6353 7 років тому +1

    Well prepared. Thank you!!

  • @a_mortal7511
    @a_mortal7511 Рік тому

    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 👍👍

  • @mokers8364
    @mokers8364 Рік тому

    Brilliant video, thank you!

  • @MLDawn
    @MLDawn 3 роки тому

    you are killing it man... big big like

  • @ausmack8039
    @ausmack8039 2 роки тому

    Right to the point, good work

  • @zma314125
    @zma314125 2 роки тому

    Thank you man! Great video.

  • @edwardwhite8253
    @edwardwhite8253 6 років тому +1

    Hotdamn this video is easy to understand, kudos to you dude

  • @ir3388
    @ir3388 5 років тому

    Clear explanation. Thank you so much.

  • @aneeshbhat7328
    @aneeshbhat7328 4 роки тому

    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.

  • @nancymackenzie6596
    @nancymackenzie6596 2 роки тому

    As with the other commenters, I found this efficient and instructive :). Thank you!

  • @brightasante3859
    @brightasante3859 5 місяців тому

    Thanks a lot for this tutorial. It helped me so much!!

  • @rabiafidan9256
    @rabiafidan9256 2 роки тому +1

    Thanks! very helpful and clear. I wish you showed how to set default values to arguments, too.

  • @alirezag6603
    @alirezag6603 6 років тому +4

    Thanks for explaining 'store_true'!!!

  • @ibrahimsevik1990
    @ibrahimsevik1990 2 роки тому

    Great Tutorial. Thank You

  • @hilta7244
    @hilta7244 4 роки тому

    Good explanation, thank you so much!

  • @andrewoussenko
    @andrewoussenko 2 роки тому

    Great presentation. Thanks a lot

  • @user-yn6ii7ys3u
    @user-yn6ii7ys3u 2 роки тому

    Great video, thank a lot!

  • @aidynabirov7728
    @aidynabirov7728 3 роки тому

    Great explanation!

  • @sunainabhamra7755
    @sunainabhamra7755 3 роки тому

    This was a very helpful video. Thank you so much.

  • @Shinykip
    @Shinykip 7 років тому +1

    Nice job. Thanks.

  • @lnd59_
    @lnd59_ 6 років тому +2

    Very well. Thanks dude! =D

  • @GAUTAMSHARMA-xu7bl
    @GAUTAMSHARMA-xu7bl 4 роки тому

    creative way to present it. thanks a lot.

  • @federicopalacio5349
    @federicopalacio5349 2 роки тому

    bro you saved me so much fuckin time at work with this tutorial, thanks.

  • @bactran7799
    @bactran7799 Рік тому

    thank you, it's really clear

  • @alkhashtee
    @alkhashtee 5 років тому

    Thank you so much. Very good informative video

  • @teodoravukovic4643
    @teodoravukovic4643 2 роки тому

    you are a hero! :)

  • @boughellabamouaad8313
    @boughellabamouaad8313 7 років тому +1

    Thank you for that tutorial

  • @niceshootW
    @niceshootW 9 місяців тому

    great video!

  • @codestorywithMIK
    @codestorywithMIK 7 років тому +1

    very helpful. Thanks

  • @idermonh3645
    @idermonh3645 Рік тому

    Well explained!

  • @w.schobel1514
    @w.schobel1514 7 років тому

    very clear. thumbs up

  • @HG-mt3vl
    @HG-mt3vl 5 років тому

    Great video, thanks

  • @AmolGautam
    @AmolGautam 4 роки тому

    Thanks , for the tutorial.

  • @joymbugua5551
    @joymbugua5551 3 роки тому

    This was so good

  • @AssadNiang
    @AssadNiang 4 роки тому

    Thank you
    Great tutorial

  • @alexandergarcia6479
    @alexandergarcia6479 4 роки тому

    thank you, it was very helpful.

  • @godamkeras4144
    @godamkeras4144 2 роки тому

    PERFECT BRO!

  • @letrung3249
    @letrung3249 6 років тому

    Great job bro

  • @kamyarjanparvari4244
    @kamyarjanparvari4244 3 роки тому

    thanks, it was great

  • @DheerajAeshdj
    @DheerajAeshdj 4 роки тому

    BEST.INTRO.EVER.

  • @yoonchaena671
    @yoonchaena671 3 роки тому

    Thank you so much~!

  • @AmitErandole
    @AmitErandole Рік тому

    so good 😊

  • @gyangaha109
    @gyangaha109 2 роки тому

    amazing bro

  • @mikehagerty9666
    @mikehagerty9666 6 років тому +1

    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!

  • @kemaldursun8192
    @kemaldursun8192 2 роки тому

    thanks so much dude

  • @abhinashmahor6227
    @abhinashmahor6227 3 роки тому

    love it

  • @Megax_youtube
    @Megax_youtube 3 роки тому

    Thx helped alot

  • @juillotine
    @juillotine 3 роки тому

    Thanks Johnny

  • @marioandresheviacavieres1923
    @marioandresheviacavieres1923 3 роки тому

    thanks a lot!!!

  • @MartinSh429
    @MartinSh429 2 роки тому

    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

  • @martinthong125
    @martinthong125 Рік тому

    nice demo

  • @MrSairamdgr8
    @MrSairamdgr8 2 роки тому

    luv u bro..

  • @Pyrografpl
    @Pyrografpl 2 роки тому

    Thank you

  • @Stripy42
    @Stripy42 2 роки тому

    It was very good. I like your clear style. How about an intermediate lesson too?

  • @alvarosalgado3121
    @alvarosalgado3121 6 років тому

    Thanks!

  • @marwanmohamed2500
    @marwanmohamed2500 2 роки тому

    awesome

  • @justchary
    @justchary 2 роки тому

    thanks!

  • @kavourakos
    @kavourakos 2 роки тому

    very nice

  • @karthiksundar7615
    @karthiksundar7615 5 років тому

    Nice one bud

  • @user-op3vy1nm8z
    @user-op3vy1nm8z Рік тому

    thx form taiwan !

  • @gunjanrajendraramteke1417
    @gunjanrajendraramteke1417 4 роки тому

    your dog is too cute

  • @gtag174
    @gtag174 Рік тому

    How do i set to display the help by default when no arguments are passed ?

  • @sunnykim471
    @sunnykim471 3 роки тому

    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)

  • @ayarzuki
    @ayarzuki 3 роки тому

    Still don't remember argparse structure and hard to work on that, hahaha

  • @mylapillivikas3910
    @mylapillivikas3910 3 роки тому

    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.

    • @JohnnyMetz
      @JohnnyMetz  3 роки тому +1

      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.

    • @mylapillivikas3910
      @mylapillivikas3910 3 роки тому

      @@JohnnyMetz Thank you

  • @akashvakil6696
    @akashvakil6696 5 років тому

    #it is always :
    if.args.long_form_of_the_argument :
    do something
    # isn't it?

    • @JohnnyMetz
      @JohnnyMetz  5 років тому

      Correct, I don't believe you can access the arguments using the short hand notation

    • @akashvakil6696
      @akashvakil6696 5 років тому

      @@JohnnyMetz Perfect, Thank you!

  • @amitupadhyay4511
    @amitupadhyay4511 2 роки тому

    no explaination and describing what the library is for etc and straight to code ? NOOOPE

  • @XinhLe
    @XinhLe 4 роки тому

    Don't recommend the doc please :)

  • @ardenshackelford7807
    @ardenshackelford7807 6 років тому +1

    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!

  • @GamingBlake2002
    @GamingBlake2002 7 років тому

    This tutorial made argparse so much easier to understand, great video!

  • @thetechegg8859
    @thetechegg8859 6 років тому +1

    Most condensed tutorial on this topics yet it was extremely helpful especially when compared to the other ones