My issue is:

I can't concatenate string and noneType object. Some attribute values are empty. It follows that label isn't displayed.

What is the solution?

def FindLabel ( [CONTENU], [NOM_OBJET_USUEL] ):
  if [CONTENU] == u"Eaux usées":
    return "<CLR red='168' >" + [NOM_OBJET_USUEL] + "</CLR>"

  elif  [CONTENU] == u"Eaux mélangées":
    return  "<CLR red='168'  >" + [NOM_OBJET_USUEL] + "</CLR>"

  elif [CONTENU] == "Eaux pluviales":
    return  "<CLR green='77' blue='168' >" + [NOM_OBJET_USUEL] + "</CLR>"

  elif  [CONTENU] == "Eaux de drainage":
    return  "<CLR green='77' blue='168' >" + [NOM_OBJET_USUEL] + "</CLR>"   

If for example [NOM_OBJET_USUEL] contains empty values, replace all occurences with ([NOM_OBJET_USUEL] if [NOM_OBJET_USUEL] else "")

This replaces NoneType with an empty string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.