if var is not None and var !="" and var !=" ":
# todo
can I write it like this?:
if var:
# todo
var is only String type.
If you want to filter out space-only string (" "):
if var and var.strip():
# ...
Becasue string that contain spaces is evaludated as True if used as predicate:
>>> bool("")
False
>>> bool(" ")
True
if var.strip(): is equivalent to that.var could be None.' ' is the only whitespace string that should be considered false, whereas ' ' * 2 or '\t' should be considered true as in the code in the question, then the answer is different :-)