Skip to content

Instantly share code, notes, and snippets.

@hcgatewood
Last active July 29, 2016 07:10
Show Gist options
  • Save hcgatewood/e1f42b371ab56037eeda to your computer and use it in GitHub Desktop.
Save hcgatewood/e1f42b371ab56037eeda to your computer and use it in GitHub Desktop.
Print a random note at the passed interval, defaulting to every 4 seconds
#!/usr/bin/env python3
'''
Prints a random note at the passed interval, defaulting to every
4 seconds.
@author Hunter Gatewood
'''
import itertools
import random
import time
import sys
notes = 'A B C D E F G'.split()
acc_symbs = ['', '♯', '♭']
combinations = [''.join(el) for el in itertools.product(notes, acc_symbs)]
try:
interval = int(sys.argv[1])
except:
interval = 4
while True:
time.sleep(interval)
print(random.choice(combinations))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment