Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 528cdb1

Browse files
committed
#3917: don't allow {} as a set display.
1 parent 8b6dc5c commit 528cdb1

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

Doc/reference/expressions.rst

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,16 @@ A set display is denoted by curly braces and distinguishable from dictionary
223223
displays by the lack of colons separating keys and values:
224224

225225
.. productionlist::
226-
set_display: "{" [`expression_list` | `comprehension`] "}"
226+
set_display: "{" (`expression_list` | `comprehension`) "}"
227227

228228
A set display yields a new mutable set object, the contents being specified by
229229
either a sequence of expressions or a comprehension. When a comma-separated
230230
list of expressions is supplied, its elements are evaluated from left to right
231231
and added to the set object. When a comprehension is supplied, the set is
232232
constructed from the elements resulting from the comprehension.
233233

234-
235-
Variables used in the generator expression are evaluated lazily in a separate
236-
scope when the :meth:`next` method is called for the generator object (in the
237-
same fashion as for normal generators). However, the :keyword:`in` expression
238-
of the leftmost :keyword:`for` clause is immediately evaluated in the current
239-
scope so that an error produced by it can be seen before any other possible
240-
error in the code that handles the generator expression. Subsequent
241-
:keyword:`for` and :keyword:`if` clauses cannot be evaluated immediately since
242-
they may depend on the previous :keyword:`for` loop. For example:
243-
``(x*y for x in range(10) for y in bar(x))``.
244-
245-
The parentheses can be omitted on calls with only one argument. See section
246-
:ref:`calls` for the detail.
234+
An empty set cannot be constructed with ``{}``; this literal constructs an empty
235+
dictionary.
247236

248237

249238
.. _dict:

0 commit comments

Comments
 (0)