diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py index a281c103de5..dae42d43074 100644 --- a/Lib/compiler/misc.py +++ b/Lib/compiler/misc.py @@ -1,3 +1,14 @@ +import types + +def flatten(tup): + elts = [] + for elt in tup: + if type(elt) == types.TupleType: + elts = elts + flatten(elt) + else: + elts.append(elt) + return elts + class Set: def __init__(self): self.elts = {} diff --git a/Tools/compiler/compiler/misc.py b/Tools/compiler/compiler/misc.py index a281c103de5..dae42d43074 100644 --- a/Tools/compiler/compiler/misc.py +++ b/Tools/compiler/compiler/misc.py @@ -1,3 +1,14 @@ +import types + +def flatten(tup): + elts = [] + for elt in tup: + if type(elt) == types.TupleType: + elts = elts + flatten(elt) + else: + elts.append(elt) + return elts + class Set: def __init__(self): self.elts = {}