Trying a feature on a percentage of users.
# Modified version of the snippet that appears in: # http://blog.disqus.com/post/789540337/partial-deployment-with-feature-switches def get_for_user(self, user): """Returns true if experimental feature should be enabled for users. percent_range determines the set of users that get access. E.g. (35, 45) does NOT mean 35-45% of users get access! It means that 10% of users get access, but only users with an ID ending in 35 to 44. """ if 'users' in self.value: percent_range = (0, 10) # 10% of users. return percent_range <= user.id % 100 < percent_range return False