diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-16 00:49:47 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-02-16 00:49:47 (GMT) |
commit | 65d4ea05d2b68df68305db82d4121246cfeb461e (patch) | |
tree | 61d58e100020f9a50459b23a487daa40e6b14343 /Tools/compiler | |
parent | 4f6bcd80fcd3d50160210d3a2328b051f76f0f5e (diff) | |
download | cpython-65d4ea05d2b68df68305db82d4121246cfeb461e.zip cpython-65d4ea05d2b68df68305db82d4121246cfeb461e.tar.gz cpython-65d4ea05d2b68df68305db82d4121246cfeb461e.tar.bz2 |
add flatten helper function
Diffstat (limited to 'Tools/compiler')
-rw-r--r-- | Tools/compiler/compiler/misc.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Tools/compiler/compiler/misc.py b/Tools/compiler/compiler/misc.py index a281c10..dae42d4 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 = {} |