[New-bugs-announce] [issue41417] SyntaxError: assignment expression within assert

Jan Češpivo report at bugs.python.org
Tue Jul 28 03:59:37 EDT 2020


New submission from Jan Češpivo <jan.cespivo at gmail.com>:

Hi,

it should be useful if assignment expression works within assertion.

For example (real use-case in tests):

assert r := re.match(r"result is (\d+)", tested_text)
assert int(r.group(1)) == expected_number

I haven't found a mention about assertions in https://www.python.org/dev/peps/pep-0572/ so it isn't technically a bug but it might be omission (?).

Thx!

----------
components: Interpreter Core
messages: 374476
nosy: jan.cespivo
priority: normal
severity: normal
status: open
title: SyntaxError: assignment expression within assert
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41417>
_______________________________________


More information about the New-bugs-announce mailing list