Solved

needed <= granted — sets with comparison operators?

AmeliaRunsOP

I didn't know you could compare sets like that.

3

Comments 5

Log in to join the discussion.

Log in Create account
  1. JackStack Solutionreplies: 2

    For sets, <= means "is a subset of". So needed <= granted is True when every needed permission is in granted. Then needed - granted gives exactly what's missing.

    2
    1. AmeliaRunsOPreplies: 1

      Reads like maths. Love it.

      3
      1. HenryWrites

        Words are friendlier for code reviews, operators for brevity. Either works.

        3
    2. BellaRossi

      needed.issubset(granted) does the same if you prefer words.

      4
      1. NoahLoops

        Real permission systems work exactly like this.

        2