this post was submitted on 22 Nov 2023
295 points (100.0% liked)

196

18051 readers
312 users here now

Be sure to follow the rule before you head out.


Rule: You must post before you leave.



Other rules

Behavior rules:

Posting rules:

NSFW: NSFW content is permitted but it must be tagged and have content warnings. Anything that doesn't adhere to this will be removed. Content warnings should be added like: [penis], [explicit description of sex]. Non-sexualized breasts of any gender are not considered inappropriate and therefore do not need to be blurred/tagged.

If you have any questions, feel free to contact us on our matrix channel or email.

Other 196's:

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Nevoic@lemm.ee 9 points 2 years ago* (last edited 2 years ago)

Python's disdain for the industry standard is wild. Every other language made in the last 20 years has proper filtering that doesn't require collecting the results back into a list after filtering like Java (granted it's even more verbose in Java but that's a low bar).

If Python had modern lambdas and filter was written in an inclusion or parametric polymorphic way, then you could write:

new_results = results.filter(x -> x)

Many languages have shorthands to refer to variables too, so it wouldn't be impossible to see:

new_results = results.filter(_)

Of course in actual Python you'd instead see:

new_results = list(filter(lambda x: x, results))

which is arguably worse than

new_results = [x for x in results if x]