python scripting(sets/frozensets)

For questions about using Classic.

Post » Thu Aug 04, 2016 6:29 am

I have been messing around in python but I don't know how to to make the sets work it looks like this
Code: Select all
list=[1,2,3,4,5]
TRIAL.SetText(set(list))


...TRIAL is the name of the text....it doesn't work with frozenset either...nothing appears
Code: Select all
list=[1,2,3,4,5]
TRIAL.SetText(frozenset(list))


I've noticed there's a lot of things I can't put in .SetText....is there a way around this? It will help me learn how to apply python in construct
B
23
S
10
G
6
Posts: 72
Reputation: 4,875

Post » Thu Aug 04, 2016 7:04 am

You probably need to convert the the value to a string first. The python str() function should do it.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Sat Aug 06, 2016 6:58 am

this works perfectly...but for some reason I can't do the same thing with an array..I used TRIAL.SetText(str(Array))
B
23
S
10
G
6
Posts: 72
Reputation: 4,875

Post » Sun Aug 07, 2016 1:31 am

I take it Array is a construct array, in which case it won't do what you want from Python. You need to loop over the construct array to get each value and then either add those values to a python array or a string.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests