Skip to Content
Daniel Arbuckle's Mastering Python
book

Daniel Arbuckle's Mastering Python

by Daniel Arbuckle
June 2017
Beginner to intermediate
274 pages
6h 49m
English
Packt Publishing
Content preview from Daniel Arbuckle's Mastering Python

Setting the name of argument

We set the name of an argument by passing it as a string to the ArgumentParser constructor's prog parameter. These changes make the help output of the program prettier and more useful, but they don't actually give the program any new capabilities.

We need to start adding argument specifications to the parser, so it can check for them in the argument list.

We do that by calling the ArgumentParser instance's add_argument method:

The argparse module recognizes two kinds of arguments:

  • Optional arguments
  • Positional arguments

As the name implies, optional arguments are not required, but if the user chooses to include ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Deep Learning for Games

Hands-On Deep Learning for Games

Micheal Lanham
Mastering PyCharm

Mastering PyCharm

Nafiul Islam
Python: Journey from Novice to Expert

Python: Journey from Novice to Expert

Fabrizio Romano, Dusty Phillips, Rick van Hattem

Publisher Resources

ISBN: 9781787283695Supplemental Content