Skip to content

Instantly share code, notes, and snippets.

@chinskiy
Created June 4, 2019 09:25
Show Gist options
  • Select an option

  • Save chinskiy/b6298c36de79d2c176e257c39e2140bf to your computer and use it in GitHub Desktop.

Select an option

Save chinskiy/b6298c36de79d2c176e257c39e2140bf to your computer and use it in GitHub Desktop.
def get_flag_value(flag_name, uid, pct=50):
random = Random()
if six.PY2:
random.seed("%s-%s" % (uid, flag_name))
else:
random.seed("%s-%s" % (uid, flag_name), version=1)
return int(random.random() * 100) + 1 <= pct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment