How to know it is a list?

Bruce Sass bsass at freenet.edmonton.ab.ca
Mon Sep 10 17:11:48 EDT 2001


On Mon, 10 Sep 2001, Henry wrote:

>   I have a newbie question. How do check if a variable is a list?

try:
    to use it like a list
except an_error_that_would_happen_if_it_isn't:
    handle the error

or maybe

try:
    list(var_to_be_converted_to_a_list)
except ...:
    handle the error


"assert" may also be useful


- Bruce





More information about the Python-list mailing list