I have a python condition statement like this
if 'small_cover' not in request.POST or 'medium_cover' not in request.POST or 'large_cover' not in request.POST:
# do somethinf here.
Can there be the shortest way than this.
I have a python condition statement like this
if 'small_cover' not in request.POST or 'medium_cover' not in request.POST or 'large_cover' not in request.POST:
# do somethinf here.
Can there be the shortest way than this.
if not all(x in request.POST for x in ('small_cover', 'medium_cover', 'large_cover')):
or even more concisely:
if not all(x+'_cover' in request.POST for x in ('small', 'medium', 'large')):
Just use any
which will short circuit if we find any of the three items are not in request.POST
if any(x not in request.POST for x in ('small_cover', 'medium_cover','large_cover')):