Think of caching a precondition, which could be expensive to compute, but is checked frequently, e.g. on every function call. Then it could make sense to store a boolean of the precondition once, and it use it within the function. But I guess there are more elegant patterns to avoid such tricks. I would consider it quick and dirty hack. You can also have a function global variable like this:
def f():
if f.precondition is None:
f.precondition = test_precondition()
if f.precondition:
# ...
else:
#...
# set the initial state
f.precondition = None
That way you avoided to use a global variable, but reduced the scope to be somehow static to a particular function. The value can also be shared across function.