0

I've got the following line:

group_index = apps["special_groups"] == group

From my understanding, group_index is being assigned the value in apps["special_groups"]. Then I see the == operator, but what does it do with the result? Or is it comparing apps["special_groups"] to group first?

3 Answers 3

4

From the Python Evaluation Order documentation:

Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand side.

So it first evaluates apps["special_groups"] == group, then assigns the result of this to group_index.

Sign up to request clarification or add additional context in comments.

1 Comment

Beat me by less than a minute! Shouldn't have stopped for that sip of water :P
1

From the Python docs, Section 5.14:

Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand side.

Therefore it evaluates the right-hand side, apps["special_groups"] == group, first, and then it assigns this result to the left-hand side, group_index.

Comments

0

It assigns the value of the boolean comparison [True or False] to the LHS variable group_index.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.