That variable name is awful, but I'm not quite able to come up with something more concise.
Long names aren't necessarily a problem as long as they explain well what is this variable. You could call it enable_x
to stress the fact its a boolean that will enable a particular treatment. But using booleans to force an execution path should be avoided whenever possible.
What is the general practice ?
To avoid this kind of flag entirely. The most elegant design is to refactor using classes and overrides :
class A:
def foo(x):
start_of_foo(x)
bar(x)
remaining_of_foo(x)
def bar(x):
pass
class B(A):
def bar(x):
do_something_with(x)
Then you can use B()
or A()
based on situation
Alternatively, if you are reluctant to use a class for this :
def foo(x, mybar=bar):
start_of_foo(x)
mybar(x)
remaining_of_foo(x)
def bar(x):
pass
def specific_bar(x):
do_something_with(x)