Hi All,
I have below snippet which use the generator to give the new ID
...
def __init__(self, id_generator = None):
if id_generator is None: id_generator = 0
if isinstance(id_generator, int):
import itertools
self._generator = itertools.count(id_generator)
else:
self._generator = id_generator
...
id = self._generator.next() #0
id = self._generator.next() #1
id = self._generator.next() #2
id = self._generator.next() #3
my question is, suppose I have an existing id number such as int(99) need to be accepted during the runtime and need the _generator to generate the ID starting from 99. looks like:
0
1
2
3
4
<---- new id number 99 be given in somehow
99
100
101
how I can feed it back to the _generator?
Just use self._generator = itertools.count(99)
or there's a better way?
More, sucn a confuse can be to be more generalized: how I can memo/assign a generator's status/value if it is not for an int type?
Thanks!