Unpacking

Noun · Development

Definitions

  1. A syntactic feature — called destructuring in JavaScript and unpacking in Python — that extracts individual values from a collection (tuple, list, dict, or object) into separate variables in a single statement. In Python, `a, b, c = [1, 2, 3]` unpacks a list, and `**kwargs` unpacks a dictionary into keyword arguments.

    In plain English: A shortcut for pulling individual values out of a collection and assigning them to separate variables in one line.

    Example: "Just unpack the tuple directly — `x, y, z = get_coordinates()` is way cleaner than indexing into the result."

Related Terms