On Jun 21, 9:17 pm, dominique <[EMAIL PROTECTED]> wrote: > Hello All, > > In a wx GUI, I would like to let the user choose between >, < or =. > So, I created a combobox and when the user chooses ">" for instance, I > wanted to return > (the objective is to send the operator into another > complex method): > Example: > if variable == ">": > return > > > But this is invalid syntax. > > How can I transform a ">" into the > operator ie without parenthesis, > so that I can load it into another function ?
Look at the operator module. In your above example: return { '>': operator.gt, '=': operator.eq, '<': operator.lt, }[variable] Cheers, John -- http://mail.python.org/mailman/listinfo/python-list