You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify Python 3.15 requirement for set comprehension unpacking in tutorial #162823
The Sets tutorial on /3/ (currently Python 3.15) demonstrates PEP 798 iterable unpacking inside a set comprehension without noting that this syntax requires Python 3.15:
Readers on Python 3.14 following the default /3/ URL encounter:
File "<python-input-0>", line 1
{*fruit for fruit in fruits}
^^^^^^SyntaxError: iterable unpacking cannot be used in comprehension
Additionally, the Python 3.14 version of Section 5.4 does not show a 3.14-compatible way to unpack or combine a sequence of sets.
Suggested changes
main and 3.15 (Doc/tutorial/datastructures.rst):
Add a brief .. versionadded:: 3.15 directive (or inline note) stating that * unpacking inside comprehensions was introduced in Python 3.15.
3.14 (Doc/tutorial/datastructures.rst, if within tutorial scope):
Add a brief example after the set comprehension block showing how to combine multiple sets in 3.14:
Similarly to list comprehensions, set comprehensions are also supported::
>>> a = {x for x in 'abracadabra' if x not in 'abc'} >>> a {'r', 'd'}
Multiple sets can also be combined using unpacking or a nested comprehension::
>>> fruits = [{'apple', 'avocado', 'apricot'}, {'banana', 'blueberry'}] >>> {item for fruit in fruits for item in fruit} {'apple', 'avocado', 'apricot', 'banana', 'blueberry'} >>> set().union(*fruits) {'apple', 'avocado', 'apricot', 'banana', 'blueberry'}
I don't think we actually add version-specific information in tutorials. We shouldn't assume that the user is too dumb to see that they're on the "stable version". And for 3.14, I don't think we need to make it more complex.
Fair enough, @picnixz. It makes sense to keep the tutorial minimal and version-agnostic.
For the record, though, this isn't about users failing to notice the version selector. Search engines route directly to /3/ (3.15), while OS-packaged and default local Python installations routinely lag 1–2 minor versions behind. When a new user copies an example from the official tutorial and hits a SyntaxError on new PEP 798 syntax, neither the traceback nor the page signals version skew—so they burn time troubleshooting valid-looking code before realizing it's a 3.14 vs. 3.15 mismatch.
I'm leaving that UX context here for reference. Closing this out.
Activity
picnixz commentedon Nov 28, 2026
I don't think we actually add version-specific information in tutorials. We shouldn't assume that the user is too dumb to see that they're on the "stable version". And for 3.14, I don't think we need to make it more complex.
newtonjose commentedon Nov 29, 2026
Fair enough, @picnixz. It makes sense to keep the tutorial minimal and version-agnostic.
For the record, though, this isn't about users failing to notice the version selector. Search engines route directly to
/3/(3.15), while OS-packaged and default local Python installations routinely lag 1–2 minor versions behind. When a new user copies an example from the official tutorial and hits aSyntaxErroron new PEP 798 syntax, neither the traceback nor the page signals version skew—so they burn time troubleshooting valid-looking code before realizing it's a 3.14 vs. 3.15 mismatch.I'm leaving that UX context here for reference. Closing this out.