kingthrillgore@lemmy.ml to 196 · 2 years agodoes this code run rulelemmy.mlimagemessage-square43linkfedilinkarrow-up1295
arrow-up1295imagedoes this code run rulelemmy.mlkingthrillgore@lemmy.ml to 196 · 2 years agomessage-square43linkfedilink
minus-squareitslilithlinkfedilinkarrow-up12·edit-22 years agoIt does! it takes a list (or other iterator) and filters out all values that are cast to boolean True. The same could be archived with results = list(filter(bool, results))
minus-squarekakes@sh.itjust.workslinkfedilinkarrow-up12·2 years agoIt would filter out values that cast to False, no?
minus-squareitslilithlinkfedilinkarrow-up2·2 years agoi wasn’t sure how to phrase it, it keeps all values that cast to True, and discards all that cast to False
It does! it takes a list (or other iterator) and filters out all values that are cast to boolean True. The same could be archived with
results = list(filter(bool, results))
It would filter out values that cast to False, no?
Like None, 0, “”, …
i wasn’t sure how to phrase it, it keeps all values that cast to True, and discards all that cast to False