]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
symbol_sequence.py: allow _flatten_list_ to work on an iterable.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 4 Nov 2018 05:43:46 +0000 (01:43 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 4 Nov 2018 05:43:46 +0000 (01:43 -0400)
mjo/symbol_sequence.py

index 2abf41b786f709afa8581c8509fd4ee6944ae0a4..977add638b001f6956b3e8af691a51a2ebf63fec 100644 (file)
@@ -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: