Script transform unexpectedly return array

Got an odd one.

I was trying to set up a script transform to essentially check the data type of a parameter, and output one of two strings based on the result. It was behaving oddly, and I managed to isolate it down to something I simply can't explain.

I reduced my script transform to:

if True:
    return 'yes'
else:
    return 'no'

Then I toggle it between if True and if False and it should return either yes or no.

If I type that out, that's exactly how it behaves. But if I copy and paste in the following:

if True:
	return 'yes',
else:
	return 'no'

...which appears to be identical, it doesn't return yes or no, it returns [yes] or no. That is, the first value returned is a single element array.

Try it yourself. Copy and paste the top code block into a script transform, and it'll return yes. Copy and paste the bottom code block into a script transform, and it'll return [yes]

What the heck is going on here?
Screen Shot 2022-11-14 at 10.40.30 am
Screen Shot 2022-11-14 at 10.40.41 am
View.zip (3.5 KB)

Okay, having it all laid out in front of me in one post, I spotted the comma after yes

:upside_down_face:

7 Likes

I think that comma is short form for creating a tuple.

3 Likes

https://rubberduckdebugging.com/ strikes again.

3 Likes