On 12/24/2009 12:05 PM Victor Subervi said...
Hi;
I have the following code:

       try:
         trueVal = form.getlist(storeColNames[i])
         colNames.append(storeColNames[i])
         if len(trueVal) > 1:
           trueVal = string.join(trueVal, ',')
           values.append(trueVal)
         elif len(trueVal) == 1:
           print storeColNames[i], trueVal, '<br />'
           trueVal = '%s' % trueVal[0]
           values.append(trueVal)
         if len(trueVal) > 0:
           sql = '%s="%s"' % (storeColNames[i], trueVal)
           sqlUpdate.append(sql)
       except:
         raise

This works fine except when storeColNames[i] returns no data. Now, if I
were dealing with getfirst instead of getlist, I could easily put in a
nonsense default data value such as '%$#' and check for that. But how
can I do that or something similar (and preferably more elegant) with
getlist, which takes only the one name parameter?
TIA,
beno


trueVal = form.getlist(storeColNames[i]) or  '%$#'

Assuming of course that 'returns no data' evaluates as false.

Emile

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to