File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed
Misc/NEWS.d/next/Documentation Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ Common syntax elements for comprehensions are:
183
183
comprehension: `assignment_expression ` `comp_for `
184
184
comp_for: ["async"] "for" `target_list ` "in" `or_test ` [`comp_iter `]
185
185
comp_iter: `comp_for ` | `comp_if `
186
- comp_if: "if" `expression_nocond ` [`comp_iter `]
186
+ comp_if: "if" `or_test ` [`comp_iter `]
187
187
188
188
The comprehension consists of a single expression followed by at least one
189
189
:keyword: `!for ` clause and zero or more :keyword: `!for ` or :keyword: `!if ` clauses.
@@ -1695,7 +1695,6 @@ Conditional expressions
1695
1695
.. productionlist :: python-grammar
1696
1696
conditional_expression: `or_test ` ["if" `or_test ` "else" `expression `]
1697
1697
expression: `conditional_expression ` | `lambda_expr `
1698
- expression_nocond: `or_test ` | `lambda_expr_nocond `
1699
1698
1700
1699
Conditional expressions (sometimes called a "ternary operator") have the lowest
1701
1700
priority of all Python operations.
@@ -1721,7 +1720,6 @@ Lambdas
1721
1720
1722
1721
.. productionlist :: python-grammar
1723
1722
lambda_expr: "lambda" [`parameter_list `] ":" `expression `
1724
- lambda_expr_nocond: "lambda" [`parameter_list `] ":" `expression_nocond `
1725
1723
1726
1724
Lambda expressions (sometimes called lambda forms) are used to create anonymous
1727
1725
functions. The expression ``lambda parameters: expression `` yields a function
Original file line number Diff line number Diff line change @@ -267,6 +267,10 @@ Other Language Changes
267
267
:func: `~operator.countOf ` of the :mod: `operator ` module.
268
268
(Contributed by Serhiy Storchaka in :issue: `40824 `.)
269
269
270
+ * Unparenthesized lambda expressions can no longer be the expression part in an
271
+ ``if `` clause in comprehensions and generator expressions. See :issue: `41848 `
272
+ and :issue: `43755 ` for details.
273
+
270
274
271
275
New Modules
272
276
===========
Original file line number Diff line number Diff line change
1
+ Update documentation to reflect that unparenthesized lambda expressions can
2
+ no longer be the expression part in an ``if `` clause in comprehensions and
3
+ generator expressions since Python 3.9.
You can’t perform that action at this time.
0 commit comments