Interview Prep/Python for DevOps/Language essentials & functions

What is unpacking, including star-unpacking?

IntermediateConceptLanguage essentials & functions
Answer
host, port = "db.internal:5432".split(":")
first, *rest = sys.argv[1:]
*_, last = path.parts
merged = {**defaults, **overrides}      # later wins
cmd = ["kubectl", *base_args, "apply", "-f", path]

Unpacking raises ValueError: too many values to unpack (or "not enough") when counts do not match, which is a useful early failure when parsing key=value lines. Use .split(":", 1) or .partition(":") when the value itself may contain the separator.

All Python for DevOps questions Roadmap: Python for automation

More on Language essentials & functions