blob: c5a0d93e6908838c1f382b386a64957f3c2ea3fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env python3
import itertools
import logging
# This module is commonly used by others in here and should avoid
# taking any unnecessary dependencies back on them.
logger = logging.getLogger(__name__)
generators = {}
def get(name: str) -> int:
"""
def __init__(self):
self.my_unique_id = id_generator.get("student_id")
"""
if name not in generators:
generators[name] = itertools.count()
x = next(generators[name])
logger.debug(f"Generated next id {x}")
return x
|