-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Milestone
Description
In fact, Completer is an implementation of the Iterator pattern. So, I think it makes sense to rewrite it as a Python iterator. Or, add .keys() and .values() methods, which would return iterators.
E.g. rewrite from:
class Completer:
...
def init(self, ...):
...
def next(self):
...
to
class Completer:
...
def __iter__(self):
...
def __next__(self):
...
So that it can be used as:
res = [item.decode("utf8") for item in completer]
instead of
res = []
while completer.next():
key = completer.key.decode('utf8')
res.append(key)
return res
Or
yield from (item.decode("utf8") for item in completer)
instead of
while completer.next():
yield completer.key.decode('utf8')
Metadata
Metadata
Assignees
Labels
No labels