MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/m8l7ip/the_new_switchcase_statement_in_python_310/grkf3ec
r/Python • u/jamescalam • Mar 19 '21
233 comments sorted by
View all comments
Show parent comments
2
How were they impossible before? You could always do
foo = bar if foo:
instead of
if foo := bar:
1 u/baconcleaner Mar 20 '21 There's always a workaround for everything ;-), but for example with the walrus operator you can assign and use objects directly in nested loops:class test: def __init__(self, v): self.v = v + 1 tests = [(obj, obj.v) for x in (11, 22, 33) if (obj := test(x))] print(tests)
1
There's always a workaround for everything ;-), but for example with the walrus operator you can assign and use objects directly in nested loops:
class test: def __init__(self, v): self.v = v + 1 tests = [(obj, obj.v) for x in (11, 22, 33) if (obj := test(x))] print(tests)
2
u/xigoi Mar 20 '21
How were they impossible before? You could always do
instead of