Le Thu, 17 Jan 2013 15:10:45 +0200, Ilkka Pelkonen firstname.lastname@example.org a écrit :
Hi Oleg, others, It's not that it can't be done, just that it does something you don't expect. I've been professionally working with C++ for nine years in large-scale Windows systems, and I do expect a boolean expression return a boolean value.
"and" is not a boolean operator, it is a shortcutting control flow operator. Basically, what you are looking for is:
flag = element.is_visible() if element else False
(or, more explicitly: flag = element.is_visible() if element is not None else False )