jroid8@lemmy.world to Programmer Humor · 1 year agoknow the features of your languagelemmy.worldimagemessage-square147fedilinkarrow-up1650arrow-down124
arrow-up1626arrow-down1imageknow the features of your languagelemmy.worldjroid8@lemmy.world to Programmer Humor · 1 year agomessage-square147fedilink
minus-squarejuggling_collielinkfedilinkarrow-up13·1 year agoYou need to be careful here though. You might not intend for 0 and None to mean the same thing.
minus-squareBumblefumble@lemm.eelinkfedilinkarrow-up3·edit-21 year agoSo this won’t do the intended thing if a is 0. Edit: Sorry I meant to reply to the parent comment, realising now you already write the exact same thing.
minus-squareunalivejoy@lemm.eelinkfedilinkEnglisharrow-up3·1 year agoAlso if a is an empty collection or str, or false.
minus-squaremaegul (he/they)linkfedilinkEnglisharrow-up1·1 year agoActually not sure what you mean by this. By my reckoning, 0 is definitely falsy in Python such that a or b will evaluate to b if a is zero.
minus-squaremaegul (he/they)linkfedilinkEnglisharrow-up1·1 year agoWell that’s part of the fun, right!? In all seriousness I very much dislike that zero is falsy in Python. It seems to me illogical and “cute”. Zero is a number much more than an empty container is a container.
You need to be careful here though. You might not intend for
0
andNone
to mean the same thing.So this won’t do the intended thing if a is 0.
Edit: Sorry I meant to reply to the parent comment, realising now you already write the exact same thing.
Also if a is an empty collection or str, or false.
Actually not sure what you mean by this. By my reckoning,
0
is definitely falsy in Python such thata or b
will evaluate tob
if a is zero.Well that’s part of the fun, right!?
In all seriousness I very much dislike that zero is falsy in Python. It seems to me illogical and “cute”. Zero is a number much more than an empty container is a container.