Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created February 8, 2020 03:34
Show Gist options
  • Save luisenriquecorona/42cddfc00cfdfbc00c93e980b7b1b907 to your computer and use it in GitHub Desktop.
Save luisenriquecorona/42cddfc00cfdfbc00c93e980b7b1b907 to your computer and use it in GitHub Desktop.
A BingoCage does one thing: picks items from a shuffled list.
import random
class BingoCage:
def __init__(self, items):
self._items = list(items)
random.shuffle(self._items)
def pick(self):
try:
return self._items.pop()
except IndexError:
raise LookupError('pick from empty BingoCage')
def __call__(self):
return self.pick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment