and later againthoughyou should use even that sparinglyand only if its parts are all fairly simpleotherwiseyou're better off coding the full if statement form to make changes easier in the future your coworkers will be happy you did stillyou may see the and/or version in code written prior to (and in python code written by ex- programmers who haven' quite let go of their dark coding pasts why you will carebooleans one common way to use the somewhat unusual behavior of python boolean operators is to select from set of objects with an or statement such as thisx or or or none assigns to the first nonempty (that istrueobject among aband cor to none if all of them are empty this works because the or operator returns one of its two objectsand it turns out to be fairly common coding paradigm in pythonto select nonempty object from among fixed-size setsimply string them together in an or expression in simpler formthis is also commonly used to designate default--the following sets to if is true (or nonempty)and to default otherwisex or default it' also important to understand the short-circuit evaluation of boolean operators and the if/elsebecause it may prevent actions from running expressions on the right of boolean operatorfor examplemight call functions that perform substantial or important workor have side effects that won' happen if the short-circuit rule takes effectif (or ()hereif returns true (or nonemptyvaluepython will never run to guarantee that both functions will be runcall them before the ortmp tmp () (if tmp or tmp you've already seen another application of this behavior in this because of the way booleans workthe expression (( and bor ccan be used to emulate an if statement--almost (see this discussion of this form for detailswe met additional boolean use cases in prior as we saw in because all objects are inherently true or falseit' common and easier in python to test an object directly if :than to compare it to an empty value (if !'':for stringthe two tests are equivalent as we also saw in the preset boolean values true and false are the same as the integers and and are useful for initializing variables in factpython' if else has slightly different order than ' zand uses more readable words its differing order was reportedly chosen in response to analysis of common usage patterns in python code according to the python folklorethis order was also chosen in part to discourage ex- programmers from overusing itremembersimple is better than complexin python and elsewhere if you have to work at packing logic into expressions like thisstatements are probably your better bet if tests and syntax rules