Skip to content

Commit 4e477f8

Browse files
committed
Add __bool__ and __next__
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 5e8d582 commit 4e477f8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bpython/repl.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ def __nonzero__(self):
199199
"""MatchesIterator is False when word hasn't been replaced yet"""
200200
return self.index != -1
201201

202+
def __bool__(self):
203+
return self.__nonzero__()
204+
202205
@property
203206
def candidate_selected(self):
204207
"""True when word selected/replaced, False when word hasn't been replaced yet"""
@@ -212,10 +215,13 @@ def current(self):
212215
raise ValueError('No current match.')
213216
return self.matches[self.index]
214217

215-
def next(self):
218+
def __next__(self):
216219
self.index = (self.index + 1) % len(self.matches)
217220
return self.matches[self.index]
218221

222+
def next(self):
223+
return self.__next__()
224+
219225
def previous(self):
220226
if self.index <= 0:
221227
self.index = len(self.matches)

0 commit comments

Comments
 (0)