Since you are calling the attr, you could just do:
def default_action():
# do something else
action = getattr(obj, 'attr', default_action)
action()
Since you are calling the attr, you could just do:
def default_action():
# do something else
action = getattr(obj, 'attr', default_action)
action()