logoalt Hacker News

IshKebabyesterday at 11:35 AM2 repliesview on HN

You should do normally do

    data = collection.get("key")
    if data is not None:
         ...
    else:
         ....

Replies

japhyryesterday at 12:03 PM

Wouldn't this be a little cleaner?

    data = collection.get("key")
    if data:
        ...
    else:
        ...
show 5 replies
echoangleyesterday at 1:11 PM

The value in the collection could be the actual value None, that’s different from the collection not having the key.

show 2 replies