Skip to content
Advertisement

Tag: readability

Python: if not val, vs if val is None

I’ve always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems: It’s not completely readable; if value is None is surely more understandable. This can have implications later (and cause subtle bugs), since things like [] and 0 will evaluate

Advertisement