X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=grab_bag.py;h=78fee37a2c5ceb7bf677cfb661609b15fc9d9413;hb=477c84bcdefc573278ec8ed8974d5be8baac562d;hp=798ebcfb154b58c3fdbf9588bcc01bc4b69d140a;hpb=ba913d3c5ec6fd5e229398ebfe9e073aaae7d73c;p=kiosk.git diff --git a/grab_bag.py b/grab_bag.py index 798ebcf..78fee37 100644 --- a/grab_bag.py +++ b/grab_bag.py @@ -1,9 +1,13 @@ #!/usr/bin/env python3 +import logging import random from typing import Iterable, List, Optional, Set +logger = logging.getLogger(__file__) + + class grab_bag(object): def __init__(self) -> None: self.contents: Set[str] = set() @@ -22,13 +26,12 @@ class grab_bag(object): def subset(self, count: int) -> Optional[List[str]]: if len(self.contents) < count: return None - subset = random.sample(self.contents, count) - return subset + return random.sample(self.contents, count) def size(self) -> int: return len(self.contents) # x = grab_bag() -# x.add_all([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) -# print x.subset(3) +# x.add_all(["oneA", "two", "three", "oneB", "four", "five", "oneC", "oneD"]) +# print(x.subset(3))