# Concat python expression

**URL:** <https://forum.inductiveautomation.com/t/concat-python-expression/3394>\
**Category:** Ignition\
**Created:** [October 6, 2011, 3:25pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394 "2011-10-06T15:25:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [October 6, 2011, 3:25pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394/1 "2011-10-06T15:25:04Z")

</div>

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 ?

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

Thanks

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [October 6, 2011, 3:29pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394/2 "2011-10-06T15:29:26Z")

</div>

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

Something like this:

```auto
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

```auto
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
```

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [October 6, 2011, 3:38pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394/3 "2011-10-06T15:38:51Z")

</div>

ah yes. That’s perfect.  
Thank you.

---

<div class="post-metadata">

**Author:** ![todd.be](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@todd.be](https://forum.inductiveautomation.com/u/todd.be)\
**Post date:** [October 6, 2011, 3:43pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394/4 "2011-10-06T15:43:57Z")

</div>

Python string substitution rules use the C format string rules:  
[en.wikipedia.org/wiki/Printf#Format\_placeholders](http://en.wikipedia.org/wiki/Printf#Format_placeholders)

option 3

```auto
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

```auto
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
```

---

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [October 6, 2011, 3:54pm UTC](https://forum.inductiveautomation.com/t/concat-python-expression/3394/5 "2011-10-06T15:54:02Z")

</div>

thanks for the link.
