No need for types, use isinstance

This commit is contained in:
Neal Norwitz 2005-11-25 03:17:59 +00:00
parent f9232678ae
commit d752f7d8e8
3 changed files with 6 additions and 9 deletions

View file

@ -1,9 +1,8 @@
import types
def flatten(tup):
elts = []
for elt in tup:
if type(elt) == types.TupleType:
if isinstance(elt, tuple):
elts = elts + flatten(elt)
else:
elts.append(elt)