R. David Murray added the comment:
The documented syntax is correct. The '[]' are part of the syntax
*specification*, not the syntax itself. They indicate an optional argument,
just as they do in most syntax diagrams.
--
nosy: +r.david.murray
resolution: -> not a bug
stage: -> reso
New submission from 劉劍峰:
the message `D.setdefault(k[,d])', compiler inform SyntaxError: invalid syntax.
I think that it woulld be D.setdefault([k, d]).
--
assignee: docs@python
components: Documentation
messages: 284015
nosy: docs@python, 劉劍峰
priority: normal
severity: normal
status: o