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

196

18140 readers
1793 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
[–] InEnduringGrowStrong@sh.itjust.works 59 points 2 years ago (4 children)

I mean this would remove False and None from a list though.

[–] lugal@sopuli.xyz 38 points 2 years ago

Also 0 and empty strings

[–] bleistift2@feddit.de 31 points 2 years ago

And empty lists, tuples, dictionaries, sets, and strings

[–] joyjoy@lemm.ee 24 points 2 years ago* (last edited 2 years ago)

results = list(filter(None, results))

[–] LostXOR@kbin.social 4 points 2 years ago (1 children)

results = [result for result in results if result != None]

[–] naught@sh.itjust.works 22 points 2 years ago (1 children)
[–] LostXOR@kbin.social 3 points 2 years ago (1 children)

You're right, though IIRC there's no functional difference when comparing to None (other than speed).

[–] AVincentInSpace@pawb.social 9 points 2 years ago

Yes there is. One invokes __ne__ on the left hand side, the other performs an identity comparison.