Skip to content

Commit 98b64e2

Browse files
committed
-
1 parent 2051ccc commit 98b64e2

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

source_py3/python_toolbox/nifty_collections/lazy_tuple.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,13 @@ def __repr__(self):
253253
The '...' denotes a non-exhausted lazy tuple.
254254
'''
255255
if self.exhausted:
256-
inner = ''.join(('(',
257-
repr(self.collected_data)[1:-1],
258-
')'))
256+
inner = repr(self.collected_data)
259257

260258
else: # not self.exhausted
261259
if self.collected_data == []:
262260
inner = '(...)'
263261
else:
264-
inner = ''.join(('(',
265-
repr(self.collected_data)[1:-1],
266-
', ...)'))
267-
262+
inner = '%s...' % repr(self.collected_data)
268263
return '<%s: %s>' % (self.__class__.__name__, inner)
269264

270265

source_py3/test_python_toolbox/test_nifty_collections/test_lazy_tuple/test_lazy_tuple.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def empty_generator():
7979
with cute_testing.RaiseAssertor(IndexError):
8080
lazy_tuple[7]
8181

82-
assert repr(lazy_tuple) == '<LazyTuple: ()>'
82+
assert repr(lazy_tuple) == '<LazyTuple: []>'
8383

8484
assert bool(LazyTuple(())) == False
8585
assert bool(lazy_tuple) == False
@@ -91,7 +91,7 @@ def test_string():
9191
string = 'meow'
9292
lazy_tuple = LazyTuple(string)
9393
assert lazy_tuple.exhausted
94-
assert repr(lazy_tuple) == "<LazyTuple: ('m', 'e', 'o', 'w')>"
94+
assert repr(lazy_tuple) == "<LazyTuple: 'meow'>"
9595
assert ''.join(lazy_tuple) == string
9696
assert ''.join(lazy_tuple[1:-1]) == string[1:-1]
9797

@@ -132,14 +132,14 @@ def test_finite_iterator():
132132

133133
assert list(itertools.islice(lazy_tuple, 0, 2)) == [0, 1]
134134
assert not lazy_tuple.exhausted
135-
assert repr(lazy_tuple) == '<LazyTuple: (0, 1, ...)>'
135+
assert repr(lazy_tuple) == '<LazyTuple: [0, 1]...>'
136136

137137
second_to_last = lazy_tuple[-2]
138138
assert second_to_last == 3
139139
assert lazy_tuple.exhausted
140140
assert len(lazy_tuple) == lazy_tuple.known_length == \
141141
len(lazy_tuple.collected_data)
142-
assert repr(lazy_tuple) == '<LazyTuple: (0, 1, 2, 3, 4)>'
142+
assert repr(lazy_tuple) == '<LazyTuple: [0, 1, 2, 3, 4]>'
143143
assert LazyTuple(reversed(LazyTuple(reversed(lazy_tuple)))) == lazy_tuple
144144

145145
assert 6 * lazy_tuple == 2 * lazy_tuple * 3 == lazy_tuple * 3 * 2 == \

0 commit comments

Comments
 (0)