Concat python expression

Hi,

How can I replace the ‘w_06_l’ by a local variable or a tag ?
I would like to calculate the value “6” based upon the name of the component and then use it as a parameter in order to have the code to be generic ?

event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent('w_06_l').visible = 1

Thanks

event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent('w_06_l').visible = 1

Something like this:

comp = "6" #or whatever
event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent("w_0%s_l"%comp).visible = 1

option 2

number = "06" #or whatever
comp = "w_%s_l"%comp
event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent(comp).visible = 1

ah yes. That’s perfect.
Thank you.

Python string substitution rules use the C format string rules:
en.wikipedia.org/wiki/Printf#Format_placeholders

option 3

number = 6 #or whatever
comp = "w_%02d_l"%comp
event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent(comp).visible = 1

option 4

number = int("6") # string must be converted to integers for use with %d
comp = "w_%02d_l"%comp
event.source.fillPaint = system.gui.color("#FFBC00CF")
event.source.parent.parent.getComponent('floorLabels').getComponent(comp).visible = 1

thanks for the link.