What are the differences between if query and if query is not None ?

foo = Item.query.filter(...).first()

I always use If too,but I always see some codes If foo is not none,something specials ?

 
You already invited:

wincent

Upvotes from: emma

Alex - designer

Upvotes from: emma

Python docs: In the context of Boolean operations, and also when expressions are used by
control flow statements, the following values are interpreted as false:
False, None, numeric zero of all types, and empty strings and containers
(including strings, tuples, lists, dictionaries, sets and frozensets). All
other values are interpreted as true. (See the __nonzero__()
special method for a way to change this.)

Tony

Upvotes from:

 0 , and {} ,cannot get through if foo

If you wanna answer this question please Login or Register