according to this page one can't use code like
if variable = something():
#do something with variable, whose value is the result of something() and is true
if a = something():
#do something with a
elif a = somethingelse():
#5 more elifs
I had this problem years ago, in 2001 -- since I was transliterating to Python from a reference-algorithm in C which used assign-and-test heavily, I was keen to keep a similar structure for the first draft (then refactor later once correctness was well tested). So I wrote a recipe in the Cookbook (see also here), which boils down to...:
class DataHolder(object): def set(self, value): self.value = value; return value
elif tree can become:
dh = DataHolder() if dh.set(something()): # do something with dh.value elif dh.set(somethingelse()): # ...
DataHolder class can clearly be embellished in various ways (and is so embellished in both the online and book versions), but this is the gist of it, and quite sufficient to answer your question.