summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-02-16 00:49:47 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-02-16 00:49:47 (GMT)
commit65d4ea05d2b68df68305db82d4121246cfeb461e (patch)
tree61d58e100020f9a50459b23a487daa40e6b14343 /Lib/compiler
parent4f6bcd80fcd3d50160210d3a2328b051f76f0f5e (diff)
downloadcpython-65d4ea05d2b68df68305db82d4121246cfeb461e.zip
cpython-65d4ea05d2b68df68305db82d4121246cfeb461e.tar.gz
cpython-65d4ea05d2b68df68305db82d4121246cfeb461e.tar.bz2
add flatten helper function
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/misc.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py
index a281c10..dae42d4 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 = {}