Quantcast
Channel: When should I use None vs False? - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Rafael Almeida for When should I use None vs False?

They are different types. Although, in practice, they behave quite similarly. You could also replace False with: "", [], (,) or 0 and everything will mostly work. Python automatically converts your...

View Article



Answer by Devesh Kumar Singh for When should I use None vs False?

If you are checking if a value is assigned or exists, you can use None.dct = {'key':'value'}x = dct.get('key', None) # Get the value or get`None if it doesn't existdef func(...): if condition: return...

View Article

Answer by Ivan Velichko for When should I use None vs False?

I would emphasize here the semantical difference rather than the behavioral.Let's consider a couple of functions:def find_user(criteria): if is_met(criteria): return User(...) return None# ...vs def...

View Article

When should I use None vs False?

From what I've seen, the only time None and False behave differently is when they're compared to each other (for equality). Am I missing something, or is it ok to use only one or the other as long as...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images