Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2017 14:50
Show Gist options
  • Save anonymous/56ec943758037387f89538a2b483e8da to your computer and use it in GitHub Desktop.
Save anonymous/56ec943758037387f89538a2b483e8da to your computer and use it in GitHub Desktop.
getopt4 created by britodfbr - https://repl.it/JYgN/4
from random import randint, random
from time import time
def gen_random(op):
try:
op = int(op)
yield {
1: time(),
2: random(),
3: randint(1, 10),
}.get(op)
except:
raise
if __name__ == '__main__':
a = gen_random(1)
b = gen_random('2')
c = gen_random('3')
print(next(a))
print(next(b))
print(next(c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment