# For loop binding Perspective

**URL:** <https://forum.inductiveautomation.com/t/for-loop-binding-perspective/56362>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [February 21, 2022, 12:54pm UTC](https://forum.inductiveautomation.com/t/for-loop-binding-perspective/56362 "2022-02-21T12:54:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Remco\_Thijssen](https://avatars.discourse-cdn.com/v4/letter/r/9fc29f/32.png) [@Remco\_Thijssen](https://forum.inductiveautomation.com/u/Remco_Thijssen)\
**Post date:** [February 21, 2022, 12:54pm UTC](https://forum.inductiveautomation.com/t/for-loop-binding-perspective/56362/1 "2022-02-21T12:54:29Z")

</div>

Hi all,

I have a question about for loop in bindings, is this possible?

I tried a for loop for looping through a list of users and check if the user has a role, but it doesn’t work.

I tried the following code:

for x in range(len(self.session.props.auth.user.roles)):  
if self.session.props.auth.user.roles == ‘Operator’:  
return ‘true’  
else:  
return ‘false’

I’m thinking about the performance because it loops continuous, which means the performance degrade, but I don’t know if this is right?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 21, 2022, 1:04pm UTC](https://forum.inductiveautomation.com/t/for-loop-binding-perspective/56362/2 "2022-02-21T13:04:51Z")

</div>

Are you trying to use Python in an expression binding? That won’t work. You can only use [Expression Functions - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Expression+Functions).

* * *

Essential tip: use the `</>` code formatting button to format your code and preserve indentation. This is essential for Python. Can you edit your question to fix it? Thanks.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 21, 2022, 1:05pm UTC](https://forum.inductiveautomation.com/t/for-loop-binding-perspective/56362/3 "2022-02-21T13:05:37Z")

</div>

Think you just want to use the `hasRole` expression - [hasRole - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/hasRole)
