Comparing two string parameters by programming

I’m trying to compare two parameters programmatically, and if the strings are equal, empty the top parameter field, but it seems I don’t do it well.

Just doing this in a CHOP Execute DAT.

  pathStart = '../container1/item'
  num = str(5)
  pathEnd = '/bg'
  mypath = pathStart + num + pathEnd
  target = op('../container2/select1')

  if target.par.top != None:
         if target.par.top == mypath:       
                 target.par.top = None

This sentence always gives me an error: if target.par.top == mypath:

Please, what am I doing wrong?

It’s tricky stuff. mypath is a string. target.par.top is actually a Parameter object. The best thing is to convert them both to Operator objects…

if target.par.top.eval() == op(mypath) :

should do it. Sometimes target.par.top gets automatically evaluated to a Operator object, the .eval() makes sure it does.

Thanks a lot Greg,
Sorry, I don’t think I have explained myself well. What I want is to compare a string of characters that is in the parameter TOP of the SELECT operator of a container (…/container1/item5/bg) with another string of characters that I write in the CHOP Execute DAT operator that is located in another container and that when it they are the same, do an action, of deleting.

Still I tried your suggestion and it doesn’t work. It keeps giving me an error in the same sentence.

Greg! Thank you very much, you gave me the clue I needed to solve it:
if target.par.top == str(‘/project1/container1/item’) + num + str(‘/bg’):