|
From: Alex M. <al...@al...> - 2001-09-24 23:49:31
|
On Monday 24 September 2001 23:49, Titus Brown wrote: ... > -> String erpFormula = ( "if ( 10 * math.log10( TransmitPower ) > 10 and > -> LineLoss + RadomeLoss > 6 ): resultant = 20; else: resultant = 10" ); > -> > -> PythonInterpreter interp = new PythonInterpreter(); > -> interp.exec( erpFormula ); > -> > -> The runtime error is: Syntax error: invalid syntax. Evidentally it > chokes on -> the else keyword. > -> > -> If I remove the else..., it runs correctly. > > The above statement isn't valid in (C)Python, either; I'd suggest you > create a multiline string. I'm not sure how to fit the 'else' statement in > on the end of a single line... There is no way to fit an if AND its else on a single line. You are fully correct that newline characters (and indentation) should be inserted instead: String erpFormula = ( "if ( 10 * math.log10( TransmitPower ) > 10 and LineLoss + RadomeLoss > 6 ):\n resultant = 20\nelse:\n resultant = 10\n" ); Alex |