#Python news: Guido accepted PEP 572. Python now has assignment expressions.
if (match := http://pattern.search (data)) is not None:
print(http://mo.group (1))
filtered_data = [y for x in data if (y := f(x)) is not None]https://www.python.org/dev/peps/pep-0572/ …
-
-
Oh no. Are we still trying to win over C++ developers?
2 replies 0 retweets 4 likes -
Replying to @EliBoyarski @raymondh
I've wanted let-bindings in list comprehensions for a long time (but I have mixed feelings about the proposal as a whole)
2 replies 0 retweets 4 likes -
e.g I would find [y := expensive_computation(x) for x in xs if some_predicate(y)] extremely useful, but some of the stuff in that proposal feels not-clean
2 replies 1 retweet 4 likes -
In these cases, I do filter(some_predicate, map(expensive_computation, xs)) When you read it a lot, it's easier to read (duh).
2 replies 0 retweets 3 likes -
Replying to @mawillcockson @joelgrus and
In case if you don't want to build intermediate lists, you can use generator expressions.
2 replies 0 retweets 0 likes -
Replying to @svetlyak40wt @mawillcockson and
that just always reads clunky to me: [y for y in (expensive_computation(x) for x in xs) if some_predicate(y)] the syntax is too close to a double for loop
2 replies 0 retweets 1 like
they're also very easy to misread if you're not the original author of the program (or are just tired)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.