def __get_dynamic_attr(self, attname, obj, default=None):
        try:
            attr = getattr(self, attname)
        except AttributeError:
            return default
        if callable(attr):
            # Check func_code.co_argcount rather than try/excepting the
            # function and catching the TypeError, because something inside
            # the function may raise the TypeError. This technique is more
            # accurate.
            if hasattr(attr, 'func_code'):
                argcount = attr.func_code.co_argcount
            else:
                argcount = attr.__call__.func_code.co_argcount
            if argcount == 2: # one argument is 'self'
                return attr(obj)
            else:
                return attr()
        return attr
Tests scenario where the stagename exists and there are two stages associated with same deployment
dataset/ETHPy150Open statesofpop/django-cal/django_cal/views.py/Events.__get_dynamic_attr--crossover with--dataset/ETHPy150Open saltstack/salt/tests/unit/states/boto_apigateway_test.py/BotoApiGatewayTestCase.test_absent_when_stage_is_valid_and_two_stages_are_associated_to_deployment