[Zope] Python Script control flow question
Evan Simpson
evan@4-am.com
Tue, 11 Sep 2001 16:35:01 -0400
H.de.Wit@SFK.NL wrote:
> if (not SQLresult):
> resultcount=0
> This doesn't return a value if the resultcount is 0, nothing seem to happen
> during testing the python script.
> if (not SQLresult):
> resultcount=0
> print resultcount
> return printed
> It is ugly, but it works. Is it possible to remove the print resultatcount
> and the return printed somehow?
Returning any false value (zero, empty string, None) from a Script will
appear to do nothing when tested. By printing it, you convert it from
the integer zero into the string "0". You could just as easily do:
return str(resultcount)
...but I wouldn't, if you plan on calling this from other code and
getting an integer back.
Cheers,
Evan @ Zope