Skip to content

Commit 30ec7ca

Browse files
committed
-
1 parent 5644a7d commit 30ec7ca

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

misc/IDE files/Wing/python_toolbox_py3.wpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ proj.directory-list = [{'dirloc': loc('../../..'),
3434
'watch_for_changes': True}]
3535
proj.file-type = 'shared'
3636
proj.home-dir = loc('../../..')
37-
proj.launch-config = {loc('../../../../../../Dropbox/Desktop/run_in_bash.py'): (''\
37+
proj.launch-config = {loc('../../../source_py3/python_toolbox/cute_iter_tools.py'): (''\
3838
'project',
3939
(u'',
4040
'launch-OHU716PSo2P5T54y'))}

source_py3/python_toolbox/address_tools/object_to_string.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import types
77
import re
88

9-
from python_toolbox import import_tools
109
from python_toolbox import dict_tools
1110
from python_toolbox import caching
1211

source_py3/python_toolbox/address_tools/string_to_object.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
import types
77

8-
from python_toolbox import import_tools
98
from python_toolbox import dict_tools
109
from python_toolbox import re_tools
1110

12-
# from . import object_to_string (at bottom of file.)
1311
from .shared import (_contained_address_pattern, _address_pattern,
1412
_get_parent_and_dict_from_namespace)
1513

@@ -90,6 +88,8 @@ def get_object_by_address(address, root=None, namespace={}):
9088
# todo: should know what exception this will raise if the address is bad /
9189
# object doesn't exist.
9290

91+
from python_toolbox import import_tools # Avoiding circular import.
92+
9393
if not _address_pattern.match(address):
9494
raise ValueError("'%s' is not a legal address." % address)
9595

@@ -203,6 +203,4 @@ def get_object_by_address(address, root=None, namespace={}):
203203

204204
# #
205205
### Finished solving recursively for a composite address. #############
206-
207-
208-
from . import object_to_string
206+

source_py3/python_toolbox/cute_iter_tools.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,13 @@ def call_until_exception(function, exception, lazy_tuple=False):
343343

344344
def _call_until_exception(function, exception):
345345
from python_toolbox import sequence_tools
346-
exceptions = sequence_tools.to_tuple(exception, item_type=BaseException)
346+
exceptions = sequence_tools.to_tuple(exception, item_type=type)
347347
try:
348-
yield function()
348+
while True:
349+
yield function()
349350
except exceptions:
350351
raise StopIteration
352+
351353

352354
def get_single_if_any(iterable,
353355
exception_on_multiple=Exception('More than one value '

source_py3/python_toolbox/nifty_collections/emitting_ordered_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
from .ordered_set import (
1111
OrderedSet, KEY, PREV, NEXT
1212
)
13-
from python_toolbox.emitting import Emitter
1413

1514

1615
class EmittingOrderedSet(OrderedSet):
1716
'''An ordered set that emits to `.emitter` every time it's modified.'''
1817

1918
def __init__(self, emitter, items=()):
2019
if emitter:
20+
from python_toolbox.emitting import Emitter
2121
assert isinstance(emitter, Emitter)
2222
self.emitter = emitter
2323
OrderedSet.__init__(self, items)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2009-2014 Ram Rachum.
2+
# This program is distributed under the MIT license.
3+
4+
import collections
5+
6+
from python_toolbox.cute_iter_tools import call_until_exception
7+
8+
9+
def test():
10+
11+
assert list(call_until_exception(collections.deque(range(7)).popleft,
12+
IndexError)) == list(range(7))
13+

0 commit comments

Comments
 (0)