summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2010-01-09 23:35:54 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2010-01-09 23:35:54 (GMT)
commitee936a21308679654b2d458166ff094ed735fef7 (patch)
tree612cd109e8ede4080f58f30ece3212d8e0f996d2 /Doc
parente36561352895170f28f77f0b4ec4292e35d1cc01 (diff)
downloadcpython-ee936a21308679654b2d458166ff094ed735fef7.zip
cpython-ee936a21308679654b2d458166ff094ed735fef7.tar.gz
cpython-ee936a21308679654b2d458166ff094ed735fef7.tar.bz2
Issue #2335: Backport set literals syntax from Python 3.x.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/expressions.rst26
1 files changed, 25 insertions, 1 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index e060670..9761f21 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -65,7 +65,7 @@ atoms is:
.. productionlist::
atom: `identifier` | `literal` | `enclosure`
enclosure: `parenth_form` | `list_display`
- : | `generator_expression` | `dict_display`
+ : | `generator_expression` | `dict_display` | `set_display`
: | `string_conversion` | `yield_atom`
@@ -281,6 +281,30 @@ datum (textually rightmost in the display) stored for a given key value
prevails.
+.. _set:
+
+Set displays
+------------
+
+.. index:: pair: set; display
+ object: set
+
+A set display is denoted by curly braces and distinguishable from dictionary
+displays by the lack of colons separating keys and values:
+
+.. productionlist::
+ set_display: "{" (`expression_list` | `comprehension`) "}"
+
+A set display yields a new mutable set object, the contents being specified by
+either a sequence of expressions or a comprehension. When a comma-separated
+list of expressions is supplied, its elements are evaluated from left to right
+and added to the set object. When a comprehension is supplied, the set is
+constructed from the elements resulting from the comprehension.
+
+An empty set cannot be constructed with ``{}``; this literal constructs an empty
+dictionary.
+
+
.. _string-conversions:
String conversions