J
jdonnell
I want to check if a value is in an array. I'm currently doing it as
follows, but I just don't like this way of doing it. It seems
unpythonic.
fieldIsRequired = true
try:
notRequiredAry.index(k)
fieldIsRequired = false
except ValueError:
pass
# throw expception if field is required and is empty
if(product[k] == '' and fieldIsRequired):
raise GMError(k + ' is required')
follows, but I just don't like this way of doing it. It seems
unpythonic.
fieldIsRequired = true
try:
notRequiredAry.index(k)
fieldIsRequired = false
except ValueError:
pass
# throw expception if field is required and is empty
if(product[k] == '' and fieldIsRequired):
raise GMError(k + ' is required')