

2·
16 days agoMy point is that if your variable can be None
then you need the same pattern for the length check.
So for the Pythonic version:
if (foo is not None) and not foo:
...
For the explicit length check:
if (foo is not None) and (len(foo) == 0):
...
Honestly you’re probably better off using type hints and catching such things with static checks and not adding the None
check.
Reading this made me wonder if I was having a stroke, because it seems like English but I don’t recognize so many of the words. 👴