This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Aude- > So I am trying to do a simple conversion of an image. > > In tools>formulas>Jython libraries, I have written this: > > def mod2temp(kmod): > if (kmod > 176) : > > temp = 418.-float(kmod) > > else: > > temp = (660.-float(kmod))/2. > > return temp > > I get the following error message: > > "There was an error in the Python library:Traceback (innermost last):(no > code object) at line 0 SyntaxError:("'return' outside > function",('<string>',11,1,"))". > > what am I missing? The return has to be at the same indentation level as the if and else: def mod2temp(kmod): if (kmod > 176) : temp = 418.-float(kmod) else: temp = (660.-float(kmod))/2. return temp Otherwise, return is outside the function mod2temp. Don Murray Ticket Details =================== Ticket ID: GCH-224785 Department: Support IDV Priority: Normal Status: Open