Python Walrus Operator

Posted on Wed 06 December 2023 in TIL • Tagged with Python

Today I learned that in Python 3.8 they added the walrus operator.

:=

This docile creature lets you do this:

if m := re.search('(\d+) inch tusks',line):
    print(f'length: {m.group(1)}')

This was badly needed.

I think I need to read all the Python 3.x "whatsnew …


Continue reading