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 @@ -185,7 +185,7 @@ Common syntax elements for comprehensions are:
185185 comprehension: `assignment_expression ` `comp_for `
186186 comp_for: ["async"] "for" `target_list ` "in" `or_test ` [`comp_iter `]
187187 comp_iter: `comp_for ` | `comp_if `
188- comp_if: "if" `expression_nocond ` [`comp_iter `]
188+ comp_if: "if" `or_test ` [`comp_iter `]
189189
190190The comprehension consists of a single expression followed by at least one
191191:keyword: `!for ` clause and zero or more :keyword: `!for ` or :keyword: `!if ` clauses.
@@ -1707,7 +1707,6 @@ Conditional expressions
17071707.. productionlist :: python-grammar
17081708 conditional_expression: `or_test ` ["if" `or_test ` "else" `expression `]
17091709 expression: `conditional_expression ` | `lambda_expr `
1710- expression_nocond: `or_test ` | `lambda_expr_nocond `
17111710
17121711Conditional expressions (sometimes called a "ternary operator") have the lowest
17131712priority of all Python operations.
@@ -1733,7 +1732,6 @@ Lambdas
17331732
17341733.. productionlist :: python-grammar
17351734 lambda_expr: "lambda" [`parameter_list `] ":" `expression `
1736- lambda_expr_nocond: "lambda" [`parameter_list `] ":" `expression_nocond `
17371735
17381736Lambda expressions (sometimes called lambda forms) are used to create anonymous
17391737functions. 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
267267 :func: `~operator.countOf ` of the :mod: `operator ` module.
268268 (Contributed by Serhiy Storchaka in :issue: `40824 `.)
269269
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+
270274
271275New Modules
272276===========
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