[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDV #GCH-224785]: Create a Jython's library



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