From d7cfc23127666e6b0f958f507bbcc8e6282c3b72 Mon Sep 17 00:00:00 2001 From: bobpaul Date: Wed, 12 Jul 2017 15:35:32 -0500 Subject: [PATCH] Update flatten function for Python3 compatibility. --- pyp3 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyp3 b/pyp3 index ec29ebe..ff7b28c 100755 --- a/pyp3 +++ b/pyp3 @@ -1351,7 +1351,8 @@ class Pyp(object): @type iterables: list ''' out = [] - if '__iter__' in dir(iterables) or type(iterables) in [list, PowerPipeList,tuple,PypList]: + safe_iterables = [list, PowerPipeList,tuple,PypList] + if type(iterables) in safe_iterables: #expand history objects if [x for x in iterables if type(x) in [HistoryObject]]: @@ -1363,7 +1364,7 @@ class Pyp(object): iterables = expanded_iterables #if [x for x in iterables if type(x) in [str, PypStr,HistoryObject,type,int,float]]: - if [x for x in iterables if type(x) not in [list,PowerPipeList,tuple,PypList]]: #str,int,etc + if [x for x in iterables if type(x) not in safe_iterables]: #str,int,etc out = out + iterables #add the lists and be done else: