René's URL Explorer Experiment


Title: Command Line Interfaces With argparse (Summary) (Video) – Real Python

Open Graph Title: Command Line Interfaces With argparse (Summary) – Real Python

Description: In the previous lesson, I showed you how to build a sub-parser. In this lesson, I’ll summarize the course and point you at some other command line parsing libraries. In this course, you learned all about the command line argument parser built into…

Open Graph Description: In the previous lesson, I showed you how to build a sub-parser. In this lesson, I’ll summarize the course and point you at some other command line parsing libraries. In this course, you learned all about the command line argument parser built into…

Opengraph URL: https://realpython.com/lessons/python-argparse-summary/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
  {
    "@context": "https://schema.org",
    "@type": "VideoObject",
    "name": "Command Line Interfaces With argparse (Summary)",
    "description": "In the previous lesson, I showed you how to build a sub\u002Dparser. In this lesson, I’ll summarize the course and point you at some other command line parsing libraries. In this course, you learned all about the command line argument parser built into…",
    "thumbnailUrl": ["https://files.realpython.com/media/Python-argparse-Guide_Watermarked.a7affa701ed5.jpg"],
    "uploadDate": "2022-09-06T14:00:00+00:00",
    "duration": "PT2M43S",
    
    "potentialAction": {
      "@type": "SeekToAction",
      "target": "https://realpython.com/lessons/python-argparse-summary/#t={seek_to_second_number}",
      "startOffset-input": "required name=seek_to_second_number"
    }
  }
  

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Python-argparse-Guide_Watermarked.a7affa701ed5.jpg
og:imagehttps://files.realpython.com/media/Python-argparse-Guide_Watermarked.a7affa701ed5.jpg
twitter:creator@realpython
og:typevideo.episode

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/lessons/python-argparse-summary/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/lessons/python-argparse-summary/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Flessons%2Fpython-argparse-summary%2F
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-argparse-command-line-interfaces
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson&utm_content=python-argparse-command-line-interfaces
https://realpython.com/courses/python-argparse-command-line-interfaces/#team
Building Command Line Interfaces With argparsehttps://realpython.com/courses/python-argparse-command-line-interfaces/
Christopher Trudeauhttps://realpython.com/courses/python-argparse-command-line-interfaces/#team
Recommended Tutorialhttps://realpython.com/command-line-interfaces-python-argparse/
Course Slides (.pdf)https://realpython.com/courses/python-argparse-command-line-interfaces/downloads/python-argparse-command-line-interfaces-slides/
Sample Code (.zip)https://realpython.com/courses/python-argparse-command-line-interfaces/downloads/python-argparse-command-line-interfaces-code/
Ask a Questionhttps://realpython.com/lessons/python-argparse-summary/#discussion
https://realpython.com/feedback/survey/course/python-argparse-command-line-interfaces/liked/?from=lesson-title
https://realpython.com/feedback/survey/course/python-argparse-command-line-interfaces/disliked/?from=lesson-title
Contentshttps://realpython.com/lessons/python-argparse-summary/#description
Transcripthttps://realpython.com/lessons/python-argparse-summary/#transcript
Discussion (8)https://realpython.com/lessons/python-argparse-summary/#discussion
official documentationhttps://docs.python.org/3/library/argparse.html
how-to guidehttps://docs.python.org/3/howto/argparse.html
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=python-argparse-command-line-interfaces
Sign-Inhttps://realpython.com/account/login/
Unlock This Lessonhttps://realpython.com/account/join/?utm_source=rp_lesson_preview&utm_content=python-argparse-command-line-interfaces
Sign-Inhttps://realpython.com/account/login/
00:00https://realpython.com/lessons/python-argparse-summary/#t=0.68
In the previous lesson, I showed you how to build a sub-parser. In this lesson,https://realpython.com/lessons/python-argparse-summary/#t=0.68
I’ll summarize the course and point you at some other command line parsinghttps://realpython.com/lessons/python-argparse-summary/#t=4.41
libraries. In this course,https://realpython.com/lessons/python-argparse-summary/#t=7.82
you learned all about the command line argument parser built into the Pythonhttps://realpython.com/lessons/python-argparse-summary/#t=11.43
standard library, called argparse.https://realpython.com/lessons/python-argparse-summary/#t=14.97
00:17https://realpython.com/lessons/python-argparse-summary/#t=17.52
This library supports both positional arguments as well as optional flags.https://realpython.com/lessons/python-argparse-summary/#t=17.52
It automatically generates help information, creating a -h flag for you.https://realpython.com/lessons/python-argparse-summary/#t=22.71
00:28https://realpython.com/lessons/python-argparse-summary/#t=28.17
You can modify how arguments are stored using the action parameter.https://realpython.com/lessons/python-argparse-summary/#t=28.17
This allows you to convert command line strings into numbers, use Boolean flags,https://realpython.com/lessons/python-argparse-summary/#t=32.02
and more.https://realpython.com/lessons/python-argparse-summary/#t=36.49
00:37https://realpython.com/lessons/python-argparse-summary/#t=37.86
You can also control how many parameters are consumed by your arguments throughhttps://realpython.com/lessons/python-argparse-summary/#t=37.86
the use ofhttps://realpython.com/lessons/python-argparse-summary/#t=41.72
nargs. nargs supports specific numbers of arguments orhttps://realpython.com/lessons/python-argparse-summary/#t=42.62
variable numbers of arguments with the special symbols *, +,https://realpython.com/lessons/python-argparse-summary/#t=47.72
and ?. argparse is pretty powerful,https://realpython.com/lessons/python-argparse-summary/#t=51.14
allowing all sorts of fine-grain control.https://realpython.com/lessons/python-argparse-summary/#t=55.93
00:58https://realpython.com/lessons/python-argparse-summary/#t=58.39
You can even specify that an argument must be one of a given set of choices,https://realpython.com/lessons/python-argparse-summary/#t=58.39
or you can create mutually exclusive groups of flags.https://realpython.com/lessons/python-argparse-summary/#t=63.45
Tired of typinghttps://realpython.com/lessons/python-argparse-summary/#t=67.88
all those arguments over and over? Built into the parser is a way of readinghttps://realpython.com/lessons/python-argparse-summary/#t=68.59
arguments from a file. This is done with an argument prefix,https://realpython.com/lessons/python-argparse-summary/#t=72.43
which is often set the @ symbol.https://realpython.com/lessons/python-argparse-summary/#t=75.88
01:19https://realpython.com/lessons/python-argparse-summary/#t=79.57
In addition to using the type parameter to convert command line strings intohttps://realpython.com/lessons/python-argparse-summary/#t=79.57
integers, you can also use any callable.https://realpython.com/lessons/python-argparse-summary/#t=83.55
This allows you to do fancier things, like directly convert the argument into ahttps://realpython.com/lessons/python-argparse-summary/#t=86.42
pathlib object. Although argparse comes with many storage actions,https://realpython.com/lessons/python-argparse-summary/#t=90.63
you can also write your own if you need something fancier. And finally,https://realpython.com/lessons/python-argparse-summary/#t=95.5
in the previous lesson, I covered how to use argparse to create sub-parsers.https://realpython.com/lessons/python-argparse-summary/#t=100.05
01:44https://realpython.com/lessons/python-argparse-summary/#t=104.1
This allows you to have your programs take commands similar to how Githttps://realpython.com/lessons/python-argparse-summary/#t=104.1
uses checkout, status, and more.https://realpython.com/lessons/python-argparse-summary/#t=108.86
01:53https://realpython.com/lessons/python-argparse-summary/#t=113.43
argparse is a pretty deep library. It’s very well documented,https://realpython.com/lessons/python-argparse-summary/#t=113.43
and there is also a how-to guide available at the Python sitehttps://realpython.com/lessons/python-argparse-summary/#t=116.59
if you want to read the details.https://realpython.com/lessons/python-argparse-summary/#t=120.03
02:02https://realpython.com/lessons/python-argparse-summary/#t=122.6
There are also several libraries out there to make argument management requirehttps://realpython.com/lessons/python-argparse-summary/#t=122.6
less code than argparse. One of the most popular is called Click.https://realpython.com/lessons/python-argparse-summary/#t=125.99
02:10https://realpython.com/lessons/python-argparse-summary/#t=130.25
It uses function decorators to create subcommands.,https://realpython.com/lessons/python-argparse-summary/#t=130.25
meaning there is less code necessary to write per sub-parser equivalent.https://realpython.com/lessons/python-argparse-summary/#t=133.15
02:18https://realpython.com/lessons/python-argparse-summary/#t=138.35
Another popular library is docopt,https://realpython.com/lessons/python-argparse-summary/#t=138.35
where you use docstrings to define your command line interface.https://realpython.com/lessons/python-argparse-summary/#t=140.89
02:25https://realpython.com/lessons/python-argparse-summary/#t=145.38
And if you want a summary,https://realpython.com/lessons/python-argparse-summary/#t=145.38
this article compares those two libraries with argparse so that you can choosehttps://realpython.com/lessons/python-argparse-summary/#t=146.55
which is best for your situation.https://realpython.com/lessons/python-argparse-summary/#t=151.04
02:35https://realpython.com/lessons/python-argparse-summary/#t=155.82
That’s all for me.https://realpython.com/lessons/python-argparse-summary/#t=155.82
I hope you found this course valuable. In the words of Siskel and Ebert,https://realpython.com/lessons/python-argparse-summary/#t=157.0
I’ll see you at the movies.https://realpython.com/lessons/python-argparse-summary/#t=160.83
Sept. 8, 2022https://realpython.com/lessons/python-argparse-summary/#comment-1e4db929-ff52-4ee7-b0c6-1af77d641487
Sept. 9, 2022https://realpython.com/lessons/python-argparse-summary/#comment-dc068dd0-271e-46b6-953d-c41030ddccaf
Oct. 3, 2022https://realpython.com/lessons/python-argparse-summary/#comment-fbdf1f25-3b29-45a7-b67f-07347ef906b3
Oct. 3, 2022https://realpython.com/lessons/python-argparse-summary/#comment-9a0d8c2c-2941-413f-898c-c1daed830725
Dec. 21, 2023https://realpython.com/lessons/python-argparse-summary/#comment-1f707a72-b6d9-49ef-8198-2b962d766a82
Dec. 21, 2023https://realpython.com/lessons/python-argparse-summary/#comment-753f45b4-78bc-475f-bfea-ebc066114375
stackoverflow.com/questions/18160078/how-do-you-write-tests-for-the-argparse-portion-of-a-python-modulehttps://stackoverflow.com/questions/18160078/how-do-you-write-tests-for-the-argparse-portion-of-a-python-module
May 7, 2024https://realpython.com/lessons/python-argparse-summary/#comment-f93a6d21-ec0b-4fff-ad47-7605bbe85dac
May 8, 2024https://realpython.com/lessons/python-argparse-summary/#comment-b0ef5d80-ed8b-4d8a-9e4e-e8d191aff792
Become a Memberhttps://realpython.com/account/join/
https://realpython.com/lessons/building-command-line-interfaces-with-argparse-quiz/
Overviewhttps://realpython.com/courses/python-argparse-command-line-interfaces/
Command Line Interfaces With argparse (Overview) 02:52 https://realpython.com/videos/python-argparse-overview/
The Basics of argparse 04:54 https://realpython.com/videos/argparse-basics/
Help and Positional vs Optional Arguments 09:25 https://realpython.com/lessons/help-positional-optional-arguments/
Available Actions 07:41 https://realpython.com/lessons/available-actions/
Multiplicity 05:28 https://realpython.com/lessons/argparse-multiplicity/
Less Common Features 06:29 https://realpython.com/lessons/less-common-features/
Callable Types and Custom Actions 05:33 https://realpython.com/lessons/callable-types-custom-actions/
Sub-parsers 06:43 https://realpython.com/lessons/subparsers/
Building Command Line Interfaces With argparse (Quiz) 11:30 https://realpython.com/lessons/building-command-line-interfaces-with-argparse-quiz/
Command Line Interfaces With argparse (Summary) 02:43 https://realpython.com/lessons/python-argparse-summary/
Privacy Policyhttps://realpython.com/privacy-policy/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.