Skip to main content
APPLIED PYTHON / IT AUTOMATION / LESSON 02

Command-Line Tools & Configuration.

Make your first Python project configurable instead of editing its source for every run. Build argument parsers, validate inputs, resolve settings, and return predictable outputs and exit codes.

Intermediate75–95 minutes plus optional local projectInteractive command builder8 coding challengesLocal CLI walkthrough
00

What you'll learn

Lesson 01 showed how to run a script from a repeatable local environment. Lesson 02 makes that project useful across different fictional sites without rewriting its source every time. Start by understanding argument strings and work toward a real read-only CLI tool.

  • Explain how shells pass argument strings to Python and test parsing from an explicit argv list.
  • Construct helpful command-line interfaces using argparse options, required arguments, defaults and choices.
  • Validate positive numeric inputs and reject malformed arguments before beginning work.
  • Handle Boolean switches and understand why --dry-run is not authorization by itself.
  • Resolve configuration in documented CLI > environment > file > built-in precedence without treating empty values as missing.
  • Parse and validate JSON settings without executing configuration as Python code.
  • Return meaningful status codes and separate report output from diagnostics.
  • Build and test a read-only configurable inventory reporter with changed arguments and datasets.
Two complementary environments: The command builder illustrates input and settings selection without executing a shell. The coding workbench runs actual Python with argparse.parse_args([...]). The full command and its process exit status should be verified in your own terminal.

Prerequisite: Complete Projects, Environments & Dependencies or have a working local Python interpreter. If you haven't used argparse before, start with the written explanations below rather than jumping straight to the coding clinic.

MAKE A SCRIPT OPERABLE
01

From hardcoded values to command-line arguments

A script that always analyzes the same fictional site isn't much of a tool. A command-line interface lets the person running it choose inputs without editing source code. The shell interprets the command text and passes an ordered list of argument strings to Python. sys.argv contains the program name at index zero and the following tokens afterward. For tests and browser practice, pass an explicit list to argparse instead of relying on the hosting interpreter's sys.argv. This gives your functions reproducible behavior without needing access to a real terminal.

Script versus arguments

python report.py --site HQ --format json provides options to one reusable program. The options become strings until a parser converts or validates them; they aren't Python statements by themselves.

Argument lists are testable data

['--site','HQ','--format','json'] is a plain list of strings. Supplying that list directly to a parser lets you test different command lines inside JoeLearns, without executing OS commands.

Quotes and spaces

A shell normally groups a quoted value with spaces as one argument, such as --site 'Main Office'. Different shells have different quoting rules; the browser explorer models an argument list rather than interpreting arbitrary shell text.

PYTHON / PREDICT THE RESULTRead before you run
import argparse
parser = argparse.ArgumentParser(prog='report.py')
parser.add_argument('--site', required=True)
args = parser.parse_args(['--site', 'HQ'])
print(args.site)
Why does this example pass a list to parse_args() instead of reading a live command typed into a shell? Reveal the explanation after predicting.

The explicit list represents the tokens a shell would supply and can be tested repeatedly. parse_args() without a list reads the current process sys.argv, which depends on the execution environment and should not be assumed in the browser.

Remember: Treat command-line arguments as explicit input. A testable parser accepts an argument list rather than requiring a real terminal.
DESCRIBE THE CONTRACT
02

Build an argparse parser with useful help

The standard-library argparse module handles recognized options, generated help text, type conversion, and common invalid-command errors. Define the tool's public contract in one function, such as build_parser(), and give every option a descriptive help message. add_argument() registers flags, while parse_args(argv) creates a Namespace from the supplied argument list. Required options demand a value; optional flags may have sensible defaults. This is more maintainable than repeatedly indexing sys.argv by hand.

Flags and positional values

A positional argument identifies something by its position, while --site HQ explicitly names an option. For important administrative actions, named flags often make commands easier to audit and review.

Help before execution

argparse adds -h / --help by default. A person should be able to learn the required arguments without reading your source. Help text is particularly important for colleagues and future-you.

Don't parse on import

Create a parser function and parse inside main(). Modules that call parse_args() at import time can unexpectedly inspect a test runner's or another program's arguments.

PYTHON / PREDICT THE RESULTRead before you run
import argparse
def build_parser():
    parser = argparse.ArgumentParser(description='Offline inventory reporter')
    parser.add_argument('--site', required=True, help='Site to report')
    parser.add_argument('--format', choices=['text', 'json'], default='text')
    return parser
args = build_parser().parse_args(['--site', 'BR1'])
print(args.site, args.format)
What happens when the supplied argument list omits --site? Does the script silently use a guessed default site? Reveal the explanation after predicting.

argparse reports that the required option is missing and normally exits with status 2. It doesn't invent a site. In the example, --format defaults to text when the user omits it.

INTERACTIVE CLI CONTRACT EXPLORER · SIMULATED ARGUMENT LIST

Change the arguments. Predict the parser result.

This explorer models how argparse would handle a fictional inventory report command. It does not run a shell command, access your files or contact a network device. The coding clinic below runs actual Python using explicit argument lists.

ILLUSTRATIVE COMMAND · NOT EXECUTEDpython inventory_report.py --site HQ --format text --limit 5 --dry-runARGUMENT TOKENS SENT TO PYTHON["--site","HQ","--format","text","--limit","5","--dry-run"]
PARSER DECISIONAccepted

The supplied option names, values and types match the illustrated parser contract.

ILLUSTRATIVE OUTPUTHQ: 5 max devices (dry-run preview)

This output is a teaching preview, not a response from a real device.

All values are fictional. The browser coding exercises are intentionally isolated and do not read your device's environment variables or files.

Remember: Describe CLI inputs in a parser, require values that cannot safely be guessed, and provide useful --help information.
VALIDATE BEFORE USING
03

Types, choices, and positive-number requirements

Every shell argument starts as text. argparse can apply type=int, type=float, a custom conversion function, or choices to reject unacceptable input before main() runs. A type=int option rejects non-integer text but still accepts negative values, so positive counts need an additional check. Raise argparse.ArgumentTypeError with a helpful message from a converter so users see a usage error rather than a mysterious traceback. For a batch size, zero must be rejected before division, not converted into a default.

Constrain numeric values

Use a small positive_int(text) helper. Convert with int(text), reject 0 and negative numbers, and raise argparse.ArgumentTypeError for invalid values. Don't silently treat a typo as one device.

Restrict selected strings

choices=['text','json'] tells argparse which formats are allowed, with --help showing the options. Normalize input deliberately if case-insensitivity is a documented feature.

Fail closed on unknown options

parse_args() rejects unrecognized arguments rather than ignoring them. Prefer that behavior to parse_known_args() unless you are intentionally forwarding remaining arguments to another well-defined parser.

PYTHON / PREDICT THE RESULTRead before you run
import argparse
def positive_int(text):
    try:
        value = int(text)
    except ValueError as error:
        raise argparse.ArgumentTypeError('enter a whole number') from error
    if value <= 0:
        raise argparse.ArgumentTypeError('must be positive')
    return value
parser = argparse.ArgumentParser()
parser.add_argument('--limit', type=positive_int, default=10)
print(parser.parse_args(['--limit', '5']).limit)
Why is type=int by itself insufficient for a 'number of devices per batch' requirement? Reveal the explanation after predicting.

type=int confirms an integer but allows zero or negative numbers. A domain-specific converter or a separate validated range check is needed to ensure the value is usable, especially when it will be a divisor.

SYNTAX BRIDGE / BEFORE YOU CODE

Boolean values can look like integers

A Python Boolean is a subclass of int. That matters when configuration says an option must be a real integer count, not merely an object that Python accepts in arithmetic.

Python / strict numeric validationRUNNABLE PYTHON · READ FIRST
print(isinstance(True, int))
print(type(True) is int)

def valid_limit(value):
    return type(value) is int and 1 <= value <= 25

print(valid_limit(True), valid_limit(5))

isinstance(True, int) is True, but type(True) is int is False. Use a strict type check when the data contract forbids Boolean values. Do this when validating JSON configuration, not just at the end of the course.

Predict and explain: Should a JSON `true` value satisfy a configuration setting that requires between 1 and 25 devices?

No. json.loads converts JSON true to Python True; a strict count should reject it rather than interpreting it as 1.

Remember: Convert and validate user input at the boundary. Reject invalid sizes clearly instead of inventing defaults.
SAFE OPTIONS
04

Defaults, Boolean flags, and explicit dry runs

Boolean command-line switches let a tool change behavior without requiring users to type 'true' or 'false' as strings. action='store_true' makes --dry-run set a Boolean to True and defaults to False when omitted. An opt-in dry-run option is useful, but for any automation capable of making changes, safer design often makes dry-run the default and requires a separate explicit --apply plus authorization for state-changing actions. This lesson's example remains read-only and creates no live changes. Explain exactly what an option would do instead of treating a flag's name as a security guarantee.

Boolean switches

parser.add_argument('--verbose', action='store_true') yields False when omitted and True when supplied. Passing '--verbose false' is not equivalent to disabling the flag.

Safe preview behavior

An offline analyzer can use --dry-run to preview how it would format or save a report, but should never claim to have changed an endpoint. Later automation lessons will cover explicit approval and an action plan.

Avoid ambiguous defaults

Give a sensible default for harmless display options such as --format text. Don't default to a production target or a write-enabled mode without an explicit operational contract.

PYTHON / PREDICT THE RESULTRead before you run
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', action='store_true')
parser.add_argument('--dry-run', action='store_true')
options = parser.parse_args(['--verbose'])
print(options.verbose, options.dry_run)
What does the example print? Does action='store_true' make a script safe by itself? Reveal the explanation after predicting.

It prints True False. The flags only choose Boolean values; actual program logic determines whether they are honored. Safety still requires permission checks, validation and explicit control over state-changing operations.

Remember: Boolean flags express intent, not authorization. Make harmless defaults and state-changing actions explicitly controlled.
ONE EFFECTIVE VALUE
05

Combine defaults, configuration files, environment and flags

As tools grow, command-line arguments shouldn't be the only place to store settings. A small JSON configuration file can provide portable non-secret defaults, environment variables can provide deployment-specific values, and CLI options can override values for a specific run. Define one documented precedence order and use it consistently: this course uses explicit CLI flag > environment value > configuration-file value > built-in default. Validate the final effective value after merging sources, and distinguish an absent option from a supplied blank value rather than using `or` everywhere. For this lesson, the configuration is a fictional Python dictionary; no environment variables are read from your computer.

Precedence is a contract

If config says site=BR1, a fictional APPLIED_SITE environment value says DCA, and the CLI supplies --site HQ, the effective site is HQ. Learners should predict the result before running the resolver.

Absence differs from blank

Use if cli_value is not None when choosing overrides. `cli_value or fallback` treats an intentionally supplied empty string as if the option were missing. Then validate empty strings rather than silently falling through.

Keep secrets out of output

Environment variables can contain sensitive values and may leak through process inspection or logs. Avoid printing tokens, keys or passwords. Later lessons will discuss approved secret-management options and their limitations.

PYTHON / PREDICT THE RESULTRead before you run
def choose(cli, env, file_value, default):
    for candidate in (cli, env, file_value):
        if candidate is not None:
            return candidate
    return default
print(choose('HQ', 'DCA', 'BR1', 'LOCAL'))
Which site wins? What changes if the CLI value is None but the environment value is DCA? Reveal the explanation after predicting.

HQ wins because an explicitly supplied CLI value takes precedence. Without it, DCA from the environment would win over BR1 from the file and LOCAL from the built-in default.

SYNTAX BRIDGE / BEFORE YOU CODE

Missing and empty are different policies

Lesson 02 intentionally treats an explicitly supplied blank CLI value as present so validation can reject it. Lesson 06's job-specific settings policy treats None and the empty string as missing when it chooses a fallback. Neither is universal; choose, document and validate the policy appropriate to each program.

Python / compare the two contractsRUNNABLE PYTHON · READ FIRST
def strict_source(cli, env, default):
    if cli is not None:
        return cli
    return env if env is not None else default

def optional_source(cli, env, default):
    if cli not in (None, ''):
        return cli
    return env if env not in (None, '') else default

print(repr(strict_source('', 'HQ', 'LOCAL')))
print(repr(optional_source('', 'HQ', 'LOCAL')))

The first function returns '' so an input validator can reject it. The second returns 'HQ' because a blank CLI setting explicitly means absent. Don't silently mix these behaviors within one tool.

Predict and explain: If your policy says a blank CLI value is invalid, should you use a truthiness check to fall back to the environment?

No. Detect presence independently from validity. Preserve the supplied blank value, then reject it at the validation step.

Remember: Document and test a precedence order. Choose only nonmissing values, then validate the effective configuration.
CONFIGURATION IS UNTRUSTED INPUT
06

Handle JSON settings and environment values carefully

A configuration file can contain malformed JSON, missing keys or values of the wrong type. Use json.loads() and catch json.JSONDecodeError for invalid document syntax. Check that the top-level value is a dictionary before reading fields. os.environ.get() returns environment values as strings, so a numeric timeout needs conversion and validation just like a CLI argument. In browser exercises, pass a fictional mapping explicitly to your functions rather than inspecting real host secrets. On a production workstation or CI runner, follow approved ways of providing secrets—never embed example credentials in downloadable learning files.

Validate shape before use

'[]' is valid JSON but isn't a settings object. {'limit': 'five'} is an object with the wrong value type for an integer requirement. Report these separately instead of pretending the configuration is ready.

Data, not executable code

Use JSON as a data format, not eval() or exec(). Configuration should describe values, not execute arbitrary Python. Use a tiny known schema for this lesson.

Keep logging explicit

Safe diagnostics can mention which source supplied a setting, but must avoid echoing passwords or tokens. Log a nonsecret field like site or format only when it truly helps troubleshooting.

PYTHON / PREDICT THE RESULTRead before you run
import json
raw = '{"site":"HQ","format":"text"}'
data = json.loads(raw)
if not isinstance(data, dict):
    raise ValueError('configuration must be an object')
print(data.get('site', 'LOCAL'))
Is `json.loads('[]')` valid, and would it be an acceptable configuration mapping for this script? Reveal the explanation after predicting.

It is valid JSON and produces a list, but the tool expects an object/dictionary. JSON syntax validity is not the same as meeting the program's configuration schema.

SYNTAX BRIDGE / BEFORE YOU CODE

Read environment variables and JSON as untrusted strings

The exercise calls for a configuration parser; a real CLI also needs to obtain and validate values from the shell environment and an optional JSON file. The environment exposes strings, even when a value looks numeric. This worked example intentionally contains no credentials.

Python / complete, safe configuration readRUNNABLE PYTHON · READ FIRST
import json
import os

file_text = '{"site": "BR1", "limit": 10}'
file_config = json.loads(file_text)
env_site = os.environ.get('NORTHSTAR_SITE')

site = env_site if env_site is not None else file_config['site']
limit = file_config['limit']
if not isinstance(site, str) or not site.strip():
    raise ValueError('invalid-site')
if type(limit) is not int or not 1 <= limit <= 25:
    raise ValueError('invalid-limit')
print(site.strip(), limit)

os.environ.get returns a string or None. json.loads returns native Python values, so validate the mapping and each field before using it. This particular example uses built-in data and doesn't require any environment variable to be configured.

Terminal / optional test variableLOCAL TERMINAL · REFERENCE
# PowerShell:
$env:NORTHSTAR_SITE = 'HQ'
# CMD:
set NORTHSTAR_SITE=HQ
# bash/zsh:
export NORTHSTAR_SITE=HQ

These are three alternative commands, not one script to execute together. Set an environment variable in the shell running your own Python script. Avoid storing tokens in the example or printing sensitive settings.

Predict and explain: Does `os.environ.get('LIMIT')` return integer 5 if you set LIMIT=5 in a shell?

No. It returns the text '5'. Convert it deliberately and reject invalid or out-of-range results.

Remember: Parse configuration as data, validate its shape and values, and keep secrets out of source, diagnostics and examples.
SCRIPTS NEED CLEAR RESULTS
07

Return exit statuses and separate output from errors

Other programs and schedulers use process exit codes to tell whether a command succeeded. By convention, 0 means success and nonzero means a problem; many tools use 2 for a command-line usage error, which argparse commonly emits for invalid arguments. Write a main(argv=None) function that returns an integer status, and use `raise SystemExit(main())` only at the actual entry point so importing the module doesn't exit. Put machine-readable results on stdout and useful diagnostics on stderr. Do not combine a successful-looking JSON report with an error message on the same output channel.

Result versus diagnostic

stdout is for the requested report; stderr is for error messages and diagnostic details. This separation allows a shell pipeline to process output without misreading warnings as report records.

Use status codes consistently

Choose and document your script's codes: for instance 0 for success, 2 for usage/invalid config, and 1 for runtime failure. These are your tool's conventions; not all software uses the same numeric meanings.

Return before exiting

Having main return an integer allows a test to assert the result without actually terminating the test runner. Only the top-level entry point calls SystemExit(main()).

PYTHON / PREDICT THE RESULTRead before you run
def main(argv=None):
    if argv == ['--bad']:
        return 2
    print('2 fictional devices')
    return 0
if __name__ == '__main__':
    raise SystemExit(main())
Why should a reusable main(argv) return a numeric status instead of calling sys.exit() from inside a helper function? Reveal the explanation after predicting.

Returning a status lets tests inspect it and other code reuse the logic without terminating the process. The top-level entry-point guard can translate that integer into an actual process exit status.

SYNTAX BRIDGE / BEFORE YOU CODE

Separate machine-readable output from diagnostic errors

When another tool consumes JSON from stdout, failure explanations should go to stderr. Exiting with status 0 must mean the defined success conditions actually happened.

Python / a status-returning mainRUNNABLE PYTHON · READ FIRST
import sys

def main():
    valid = False
    if not valid:
        print('Invalid sample input', file=sys.stderr)
        return 2
    print('{"ok": true}')
    return 0

print('Exit status:', main())

print(..., file=sys.stderr) sends a diagnostic to the error stream; print() normally targets stdout. A separate local CLI can use raise SystemExit(main()) under the entry-point guard to make the returned integer the process exit code.

Predict and explain: Why is reporting `{'ok':false}` on stdout and exiting 0 risky for a scheduled CLI?

Many schedulers treat process exit 0 as success. An invalid report must not look like a completed job; return a documented nonzero status.

Remember: Return explicit status codes, reserve stdout for intended output and use stderr for errors.
CONNECT CLI TO THE FIRST PROJECT
08

Build a small, testable offline report command

You now have the pieces to make Lesson 01's report configurable. Define build_parser(), parse a supplied argument list, resolve any documented settings, validate input counts and format a report without touching live resources. Keep the data transformation in a pure function and let main(argv) handle parsing, messages and exit codes. A safe first command could be `python inventory_report.py --site HQ --format text --limit 5`. It should operate only on local, fictional data in this stage. When the CLI works for valid arguments, test a missing site, invalid limit, unknown option and changed inventory before calling it ready.

One parsing boundary

build_parser() defines the contract; main(argv) calls parser.parse_args(argv). Keeping CLI interpretation out of reporting helpers allows the same report logic to be reused by tests or future services.

Test the command contract

Use an explicit `['--site','HQ','--limit','5']` list in the browser to simulate tokens. Test the local shell command on your computer after copying the code to your project.

Read-only by default

Output only fictional summaries. Avoid network calls and real file mutation; later lessons will teach safe filesystem handling and explicit operational controls.

PYTHON / PREDICT THE RESULTRead before you run
import argparse
def build_parser():
    p = argparse.ArgumentParser(prog='inventory_report.py')
    p.add_argument('--site', required=True)
    p.add_argument('--format', choices=['text','json'], default='text')
    return p
args = build_parser().parse_args(['--site','HQ'])
print(args.site, args.format)
What parts of this command should you be able to test without an actual terminal, and what still needs a local run? Reveal the explanation after predicting.

You can test parser behavior, validation, config resolution and report formatting using explicit argument lists in real Python. The actual shell command, environment setup, process exit status and filesystem interactions require local verification.

Remember: Keep parsing, configuration and reporting as testable functions, then prove the actual command works locally with fictional data.
LOCAL PRACTICE / VERIFY THE PROCESS
09

Run a complete CLI on your own computer

Replace the fictional inventory_report.py file from Lesson 01 with this sample code. This example requires no extra dependencies, writes no files and makes no network requests. Run it using the Python interpreter from your project's virtual environment. The flags choose a site, output format and maximum number of matching records. The optional --dry-run flag annotates a preview; the script never changes real devices or files regardless of that flag.

inventory_report.py · COPY INTO YOUR LOCAL PROJECTNot executed on the site
import argparse
import json

INVENTORY = [
    {'host': 'SW-01', 'site': 'HQ', 'status': 'online'},
    {'host': 'AP-02', 'site': 'HQ', 'status': 'offline'},
    {'host': 'FW-01', 'site': 'BR1', 'status': 'online'},
]

def positive_int(text):
    try:
        value = int(text)
    except ValueError as exc:
        raise argparse.ArgumentTypeError('Enter a whole number') from exc
    if value <= 0:
        raise argparse.ArgumentTypeError('Limit must be positive')
    return value

def build_parser():
    parser = argparse.ArgumentParser(description='Offline, read-only inventory sample')
    parser.add_argument('--site', required=True)
    parser.add_argument('--format', choices=['text', 'json'], default='text')
    parser.add_argument('--limit', type=positive_int, default=10)
    parser.add_argument('--dry-run', action='store_true', help='annotate preview output; no writes')
    return parser

def main(argv=None):
    args = build_parser().parse_args(argv)
    devices = [row for row in INVENTORY if row['site'] == args.site][:args.limit]
    offline = sum(row['status'].strip().lower() == 'offline' for row in devices)
    report = {'site': args.site, 'total': len(devices), 'offline': offline}
    if args.dry_run:
        report['dry_run'] = True
    if args.format == 'json':
        print(json.dumps(report, sort_keys=True))
    else:
        suffix = ' [dry-run]' if args.dry_run else ''
        print(f"{args.site}: {offline}/{len(devices)} offline{suffix}")
    return 0

if __name__ == '__main__':
    raise SystemExit(main())

Run four different commands

After activating the virtual environment, run the commands below. If activation is unavailable, use the environment's Python executable directly as shown in Lesson 01. The local shell determines quoting and command resolution.

python inventory_report.py --site HQpython inventory_report.py --site BR1 --format jsonpython inventory_report.py --site HQ --limit 1python inventory_report.py --help

Verify both success and failure

Expect HQ: 1/2 offline for the first command, a JSON report with BR1 values for the second, and HQ: 0/1 offline for the third because only the first matching HQ record is included. An invalid --limit 0 must produce a usage error, not a fabricated report. --help should explain the valid arguments.

Safety boundary: This exercise works against the static fictional INVENTORY list. It is not a network scanner or device management utility. A production-facing CLI needs additional controls, credentials, auditability and safe defaults, which subsequent lessons will address.

10 / APPLY IT YOURSELF
10

Build your first parser in real Python

The first coding challenge requires a function that parses an explicit list of arguments. Start there, then work through defaults, type validation, Boolean options, precedence, JSON configuration, exit status and the independent offline report. You can Run with changed code and Check against several datasets.

JOELEARNS / PYTHON WORKBENCH

Write it. Run it. Understand it.

Build reusable argparse parsers, validate CLI input and test configuration logic with explicit argument lists. Shell execution happens on your computer.

Python 3.14 · in-browser
CHALLENGE 01 / 8 · BEGINNER

Parse a supplied argument list

Define parse_site(argv) using argparse.ArgumentParser with a required --site option. Return the parsed site string, not a Namespace, and do not read sys.argv directly. Use the supplied argv list for 'HQ' and print 'Site: HQ'. The grader calls your function with other site values, and checks that omitting --site is an argparse usage error rather than a guessed default.

EXPECTED OUTPUTSite: HQ
script.py editableCtrl / Cmd + Enter to run
Your code is stored only in session storage when enabled. Never paste secrets. Clearing this option clears saved drafts, not the editor.
Code executes only when you choose Run or Check. No account needed.
HINTS · OPTIONAL

Try solving it before asking for help. Hints never show a completed program.

PYTHON OUTPUTReady

Your printed output and errors will appear here.

VARIABLE TRACER

Run the code, then step through the executed lines to watch variable values change.

About this environment: The Python runtime is loaded on demand from a version-pinned CDN and runs inside a sandboxed, opaque-origin browser frame. Runs have a time limit. OS/network automation is outside this introductory workbench. If your code calls input(), a response panel appears to supply text to those calls. Don't paste secrets or untrusted scripts.

Next required step: complete the 8-challenge Practice milestone →
NEXT STEP / PRACTICE

Turn a script into a predictable tool.

Don't memorize a single valid command. Test missing required arguments, alternate formats, empty inventories and invalid numeric values. The clinic uses the actual Python interpreter and a controlled argument list.

Continue to all eight CLI coding challenges →Next: Filesystem & Structured Data Pipelines →Applied Python learning path →
11

Official references

Python's standard library documents how argparse handles choices, types, errors and help. Refer to those details when you discover an edge case rather than inferring behavior from a simulated example.

NEXT REQUIRED STEP · APPLIED PYTHON FOR IT AUTOMATION

Complete the Practice milestone

You've reached the end of this written lesson. Your next step is practice—complete Command-Line Tools Coding Clinic before proceeding to a new lesson. This is milestone 4 of 13. You can revisit the explanation whenever you need it.