how to find the type of a list element?

Carl Bray cbray at orchestream.com
Mon Nov 20 05:53:00 EST 2000


You can also use thes types module (3.4 Library Reference) to check the
type.

if type(element) is types.ListType:

elif type(element) is types.TupleType:


<lobozc at my-deja.com> wrote in message news:8v7qsd$poo$1 at nnrp1.deja.com...
> a list like [1,2,3,[4,5],6,7] is passed to a procedure
> how can a procedure find whether a list element is a 'scalar' or a list?
>
> I know I could, say, try to use exceptions for that - but I hope there
> is a better way.
>
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.





More information about the Python-list mailing list