kingthrillgore to 196@lemmy.blahaj.zone • 1 year agodoes this code run rulelemmy.mlimagemessage-square44fedilinkarrow-up1295
arrow-up1295imagedoes this code run rulelemmy.mlkingthrillgore to 196@lemmy.blahaj.zone • 1 year agomessage-square44fedilink
minus-squareInEnduringGrowStrong@sh.itjust.workslinkfedilink59•1 year agoI mean this would remove False and None from a list though.
minus-square@bleistift2@feddit.delinkfedilinkEnglish31•1 year agoAnd empty lists, tuples, dictionaries, sets, and strings
minus-squareLostXORlinkfedilink4•1 year agoresults = [result for result in results if result != None]
minus-squareLostXORlinkfedilink3•1 year agoYou’re right, though IIRC there’s no functional difference when comparing to None (other than speed).
minus-square@AVincentInSpace@pawb.sociallinkfedilinkEnglish9•1 year agoYes there is. One invokes __ne__ on the left hand side, the other performs an identity comparison.
I mean this would remove False and None from a list though.
Also 0 and empty strings
And empty lists, tuples, dictionaries, sets, and strings
results = list(filter(None, results))
results = [result for result in results if result != None]
Should be
is not None
(:You’re right, though IIRC there’s no functional difference when comparing to None (other than speed).
Yes there is. One invokes
__ne__
on the left hand side, the other performs an identity comparison.