Flatten... or How to determine sequenceability?

Delaney, Timothy tdelaney at avaya.com
Sun May 27 21:28:33 EDT 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)

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

Tim Delaney




More information about the Python-list mailing list