From 4d740ff36c55bdfc09efb677a49d75f9df2d7e99 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 4 Nov 2018 01:43:46 -0400 Subject: [PATCH] symbol_sequence.py: allow _flatten_list_ to work on an iterable. --- mjo/symbol_sequence.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mjo/symbol_sequence.py b/mjo/symbol_sequence.py index 2abf41b..977add6 100644 --- a/mjo/symbol_sequence.py +++ b/mjo/symbol_sequence.py @@ -175,9 +175,10 @@ class SymbolSequence: result = [] for item in l: - if isinstance(item, list): + try: + item = iter(item) result += self._flatten_list_(item) - else: + except TypeError: result += [item] return result @@ -332,7 +333,7 @@ class SymbolSequence: for w in v ) # This might be nested... - maybe_nested_list = [ s._subscript_tuple_(args) for s in ss ] + maybe_nested_list = ( s._subscript_tuple_(args) for s in ss ) return self._flatten_list_(maybe_nested_list) else: -- 2.44.2