3 ms·
Didn't read this pep, but have they considered C-like assignment, like: if (foo = func()) is not None: ... I find this more readable and uniform t
by dig1 8y ago
Didn't read this pep, but have they considered C-like assignment, like:
if (foo = func()) is not None:
...
I find this more readable and uniform than using := construct.
- rbanffy 8y agoThis can be easily confused with an equality comparison. That's why some in languages where assignment returns values favor "Yoda conditions"
- duckerude 8y agoBecause it's easy to accidentally type foo = func() when you meant foo == func(). That mistake happens so often in C that modern compilers warn you unless you put an extra set of parentheses around it. It would also cause ambiguity with keyword arguments. You'd have to write foo((x = 3)) because foo(x = 3) already has a meaning. I think foo(x := 3) is clearer. Maybe it would have been best to use := for all assignment. But it's too late for that.