Skip to content

Commit 848be93

Browse files
committed
-
1 parent 2f35283 commit 848be93

File tree

7 files changed

+9
-22
lines changed

7 files changed

+9
-22
lines changed

README.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ Python Toolbox is at version 0.6.0, which is an alpha release. It's being used i
3838

3939
## Next tasks ##
4040

41-
Making Python Toolbox support Python 3.x, and the packaging arrangements necessary.
42-
4341
Adding more useful tools.
4442

4543
## Future ##

source_py3/python_toolbox/cute_iter_tools.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def iterate_overlapping_subsequences(iterable, length=2, wrap_around=False):
3030
2, 3), (2, 3, 0), (3, 0, 1)]`.
3131
'''
3232
if length == 1:
33-
for item in iterable:
34-
yield item
33+
yield from iterable
3534

3635
assert length >= 2
3736

@@ -79,8 +78,7 @@ def shorten(iterable, n):
7978
'''
8079

8180
if n == infinity:
82-
for thing in iterable:
83-
yield thing
81+
yield from iterable
8482
raise StopIteration
8583

8684
assert isinstance(n, int)
@@ -196,8 +194,7 @@ def sentinel(counter=([fill_value] * (len(iterables) - 1)).pop):
196194
iterables = [itertools.chain(iterable, sentinel(), fillers) for iterable
197195
in iterables]
198196
try:
199-
for tuple_ in zip(*iterables):
200-
yield tuple_
197+
yield from zip(*iterables)
201198
except IndexError:
202199
raise StopIteration
203200

source_py3/python_toolbox/queue_tools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def iterate(queue, block=False, limit_to_original_size=False,
4040
not _platform_supports_multiprocessing_qsize():
4141

4242
if _prefetch_if_no_qsize:
43-
for item in dump(queue):
44-
yield item
43+
yield from dump(queue)
4544
raise StopIteration
4645
raise NotImplementedError(
4746
"This platform doesn't support `qsize` for `multiprocessing` "

source_py3/python_toolbox/sequence_tools.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def combinations(sequence, n=None, start=0):
5858
length = len(sequence) - start
5959
iterators = (combinations(sequence, n=i, start=start) for i
6060
in range(1, length + 1))
61-
for item in itertools.chain(*iterators):
62-
yield item
61+
yield from itertools.chain(*iterators)
6362

6463
elif n == 1:
6564
for thing in itertools.islice(sequence, start, None):

source_py3/python_toolbox/sys_tools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ def __init__(self, stdout=True, stderr=True):
4747

4848
def manage_context(self):
4949
'''Manage the `OutputCapturer`'s context.'''
50-
with self._stdout_temp_setter:
51-
with self._stderr_temp_setter:
52-
yield self
50+
with self._stdout_temp_setter, self._stderr_temp_setter:
51+
yield self
5352

5453
output = property(lambda self: self.string_io.getvalue(),
5554
doc='''The string of output that was captured.''')

source_py3/test_python_toolbox/test_cute_iter_tools/test_shorten.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ def test():
3232
def test_dont_pull_extra_item():
3333
'''Test that `shorten` doesn't pull an extra member from the iterable.'''
3434
def generator():
35-
yield 1
36-
yield 2
37-
yield 3
35+
yield from [1, 2, 3]
3836
raise Exception
3937

4038
nose.tools.assert_raises(Exception, lambda: list(generator()))

source_py3/test_python_toolbox/test_persistent/test_cross_process_persistent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ def test():
4444
checkers = [_check_deepcopying, _check_process_passing]
4545
cross_process_persistent_classes = [A, CrossProcessPersistent]
4646

47-
iterator = cute_iter_tools.product(
47+
yield from cute_iter_tools.product(
4848
checkers,
4949
cross_process_persistent_classes,
5050
)
5151

52-
for checker, cross_process_persistent_class in iterator:
53-
yield checker, cross_process_persistent_class
54-
5552

5653
def _check_deepcopying(cross_process_persistent_class):
5754
'''Test that CPPs maintain their identities when faux-deepcopied.'''

0 commit comments

Comments
 (0)