1- from itertools import takewhile , izip , izip_longest , dropwhile , imap , chain
1+ from builtins import map
2+ from builtins import zip
3+ from builtins import object
4+ from itertools import takewhile , dropwhile , chain
5+ try :
6+ from itertools import zip_longest as zip_longest
7+ except :
8+ from itertools import izip_longest as zip_longest
29
310
411def common_prefix ( xs , ys ):
@@ -18,7 +25,7 @@ def common_prefix( xs, ys ):
1825 >>> list( common_prefix('A','B') )
1926 []
2027 """
21- return imap ( lambda ( x , y ): x , takewhile ( lambda ( a , b ): a == b , izip ( xs , ys ) ) )
28+ return map ( lambda x_y : x_y [ 0 ] , takewhile ( lambda a_b : a_b [ 0 ] == a_b [ 1 ], zip ( xs , ys ) ) )
2229
2330
2431def disparate_suffix ( xs , ys ):
@@ -38,7 +45,7 @@ def disparate_suffix( xs, ys ):
3845 >>> list( disparate_suffix('A','B') )
3946 [('A', 'B')]
4047 """
41- return dropwhile ( lambda ( a , b ): a == b , izip_longest ( xs , ys ) )
48+ return dropwhile ( lambda a_b1 : a_b1 [ 0 ] == a_b1 [ 1 ], zip_longest ( xs , ys ) )
4249
4350
4451def flatten ( iterables ):
@@ -121,7 +128,7 @@ def expand( x ):
121128 i = x ,
122129 return i
123130
124- return flatten ( imap ( expand , self .args ) )
131+ return flatten ( map ( expand , self .args ) )
125132
126133
127134# noinspection PyPep8Naming
@@ -166,4 +173,4 @@ def expand( x ):
166173 except AttributeError :
167174 return x ,
168175
169- return flatten ( imap ( expand , self .iterables ) )
176+ return flatten ( map ( expand , self .iterables ) )
0 commit comments