Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

this has nothing to do with the walrus operator and everything to do with how string.format works in python https://docs.python.org/3/library/string.html#format-string-...

Edit: someone downvoted me because they don't understand there is no walrus operator here

    print(f"{a:=10}")


They obviously meant the second example:

     >>> print(f"{(a:=10)}")


the output of the second example is "obvious" so i don't see the problem.


Neither of the examples is problematic on its own; it's the fact that the language supports both of them. They're very hard to distinguish at-a-glance yet behave entirely differently.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: