[issue42954] new "if-as" syntax

Steven D'Aprano report at bugs.python.org
Mon Jan 18 05:05:45 EST 2021


Steven D'Aprano <steve+python at pearwood.info> added the comment:

Use the walrus operator:

    if profile := users.get(uid, None) is not None:
        print(f"user: {profile['name']}")

----------
nosy: +steven.daprano
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list