Flatten... or How to determine sequenceability?

Delaney, Timothy tdelaney at avaya.com
Mon May 28 03:28:33 CEST 2001

> Alex Martelli wrote:
> > I'm almost tempted to propose a tiny extension module, since
> > the C-API level *DOES* expose an "is-a-sequence" test...:
> or you could import the "operator" module, and use
> the operator.isSequenceType(obj) predicate.

Another option:

def f (l)

        l = list(l)
    except TypeError:
        # not a sequence

Tim Delaney

More information about the Python-list mailing list