On this page
  1. argparse.Namespace
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

argparse.Namespace

Prev: argparse.MetavarTypeHelpFormatter | Up: argparse | Next: argparse.RawDescriptionHelpFormatter
Rel: argparse.Action, argparse.ArgumentDefaultsHelpFormatter, argparse.ArgumentError, argparse.ArgumentParser
Ref: docs.python.org — argparse.Namespace
Tags: #public #python3 #stdlib #argparse


Import

import argparse
from argparse import Namespace

Signature & Overview

argparse.Namespace(**kwargs)

Simple object for storing attributes.

Usage

import argparse

ns = argparse.Namespace(host="localhost", port=8080)
assert ns.host == "localhost" and vars(ns) == {"host": "localhost", "port": 8080}

Gotchas

REPL Inspect

from argparse import Namespace
help(Namespace)

Linked from

Related notes