We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

syntax-target

A target is an identifier or another valid assignment target.

A target list is a comma-separated list of targets.

See assignments.

Assignment of an object to a target list is recursively defined as follows.

  • If the target list is a single target: The object is assigned to that target.

  • If the target list is a comma-separated list of targets: The object must be a sequence with the same number of items as there are targets in the target list, and the items are assigned, from left to right, to the corresponding targets.

Assignment of an object to a single target is recursively defined as follows.

  • If the target is an identifier (name):

    • If the name does not occur in a global statement in the current code block: the name is bound to the object in the current local namespace.
    • Otherwise: the name is bound to the object in the current global namespace.

    The name is rebound if it was already bound. This may cause the reference count for the object previously bound to the name to reach zero, causing the object to be deallocated and its destructor (if it has one) to be called.

  • If the target is a target list enclosed in parentheses or in square brackets: The object must be a sequence with the same number of items as there are targets in the target list, and its items are assigned, from left to right, to the corresponding targets.

  • If the target is an attribute reference, see attribute-references.

  • If the target is a subscription, see subscriptions.

  • If the target is a slicing, see slicings.