Many times in open source codes of django python , I have seen the scenario like this
if request.META and 'HTTP_REFERER' in request.META:
Similarly I have seen these two if conditions also
if request.POST and 'next' in request.POST:
if request.GET and 'next' in request.GET:
I believe that only one condition is suffice to check the if condition in these cases like
if 'HTTP_REFERER' in request.META:
if 'next' in request.POST:
if 'next' in request.GET:
So why most of the time people use the earlier once, Is it just like double checking or there are some scenarios at which the first double check conditions may be useful while the later single check conditions might fail?
I’ve just grepped the whole (current git) source of django, and hadn’t found a single occurrence of all three conditionals you mentioned.
And you are perfectly right with the one condition sufficing it as long as you can assume that all the three dictionaries are set. And looking at django code, I believe you can assume that.
Edit: also the django documentation suggests that those dictionaries will always be set.