How to concatenate strings in Vision event Scripting

I pull three strings from three components, and would like to join them together into one CSV string.
Python uses + to concatenate, but that does not work, I get a TypeError: bad operand type for unary + error.
For example:

if(event.source.parent.selected_option)==1:
	comments = event.source.parent.getComponent('Radio Button').text + ',' 
	+ event.source.parent.getComponent('Dropdown').selectedStringValue
	+ ',' + event.source.parent.getComponent('Dropdown 1').selectedStringValue

It does not like the & symbol either. I have not found a function, yet, that does this.

Thank you

The plus symbol isn't the problem, your line wrapping is. You need to put all the concatenation on one line, or use a different line ending to tell Python it's all one statement, or use a different mechanism for concatenation entirely. There's a bunch of options, but this is entirely a syntax error.

What could I use as a different line ending?

Generally the \ character is used in this scenario.

Sorry Paul,
I realized after I walked away I could have looked this up easily. Got a lot of things on my plate and spaced it. And thank you!

2 Likes