projects
/
kiosk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Testosterone and sensitivity.
[kiosk.git]
/
grab_bag.py
diff --git
a/grab_bag.py
b/grab_bag.py
index 49582fb16e6fafe2688d952abccdfe6d098fff7b..b1da60c1d84909ab12d436b761f4b25e6e9df69e 100644
(file)
--- a/
grab_bag.py
+++ b/
grab_bag.py
@@
-1,29
+1,37
@@
+#!/usr/bin/env python3
+
+import logging
import random
import random
+from typing import Iterable, List, Optional, Set
+
+
+logger = logging.getLogger(__name__)
+
class grab_bag(object):
class grab_bag(object):
- def __init__(self):
- self.contents = set()
+ def __init__(self)
-> None
:
+ self.contents
: Set[str]
= set()
- def clear(self):
+ def clear(self)
-> None
:
self.contents.clear()
self.contents.clear()
- def add(self, item
)
:
+ def add(self, item
: str) -> None
:
if item not in self.contents:
self.contents.add(item)
if item not in self.contents:
self.contents.add(item)
- def add_all(self, collection
)
:
+ def add_all(self, collection
: Iterable[str]) -> None
:
for x in collection:
self.add(x)
for x in collection:
self.add(x)
- def subset(self, count
)
:
+ def subset(self, count
: int) -> Optional[List[str]]
:
if len(self.contents) < count:
return None
if len(self.contents) < count:
return None
- subset = random.sample(self.contents, count)
- return subset
+ return random.sample(self.contents, count)
- def size(self):
+ def size(self)
-> int
:
return len(self.contents)
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 = grab_bag()
+# x.add_all(["oneA", "two", "three", "oneB", "four", "five", "oneC", "oneD"])
+# print(x.subset(3))