mercredi 16 mai 2018

Syntax Error in Python If Statement - SAP Data Hub

quick question regarding if elif statement. I am new to python therefore not sure what is wrong in the below code.

import sys
reload(sys)
sys.setdefaultencoding('utf8')

def on_input(msg): api.send("out", msg.attributes["polarity"] + "," + msg.body + "," + (if msg.attributes["polarity"] == '0.000' : 'Neutral' elif msg.attributes["polarity"] > '0.000' and msg.attributes["polarity"] <= '0.300' : 'Positive' elif msg.attributes["polarity"] > '0.301' and msg.attributes["polarity"] <= '0.800' : 'Strong Positive' elif msg.attributes["polarity"] < '0.000' and msg.attributes["polarity"] >= '-0.500' : 'Negative' elif msg.attributes["polarity"] < '-0.501' and msg.attributes["polarity"] >= '-0.800' : 'Strong Negative'))

api.set_port_callback("in", on_input)

I only can see that there is a syntax error in my application but no detailed error.

Please do the needful and thanks in advance.

Mahesh

Aucun commentaire:

Enregistrer un commentaire