[New-bugs-announce] [issue33878] Doc: Assignment statement to tuple or list: case missing.

Julien Palard report at bugs.python.org
Sat Jun 16 09:01:46 EDT 2018


New submission from Julien Palard <julien+python at palard.fr>:

In [1] I read:

> If the target list is a comma-separated list of targets, or a single target in square brackets

This come from https://bugs.python.org/issue23275 (patch is [2]).

I suspect there's a missing case "list of targets in square brackets" (and to be pedantic "list of targets in parenthesis").

The specialized documentation about single-valued targets in sequence-like construction come from this difference:

    >>> (a) = 42
    >>> a
    42

    >>> [a] = [42]
    >>> a
    42


which is correctly described the line before:

> If the target list is a single target in parentheses: The object is assigned to that target.

So the correct way to state it may be:

> Else the object must be an iterable 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.

The `Else`, coupled with the existing "Assignment of an object to a target list, optionally enclosed in parentheses or square brackets" covers properly the cases:

- Multiple target separated by comas (already covered)
- Multiple target enclosed by parenthesis and brackets (not covered)
- Single target enclosed by angle brackets (already covered)


[1]: https://docs.python.org/3.7/reference/simple_stmts.html#assignment-statements
[2]: https://bugs.python.org/file42878/issue23275_v4.diff

----------
assignee: docs at python
components: Documentation
messages: 319735
nosy: docs at python, martin.panter, mdk
priority: normal
severity: normal
status: open
title: Doc: Assignment statement to tuple or list: case missing.
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33878>
_______________________________________


More information about the New-bugs-announce mailing list