how can i check whether a variable is iterable in my code?

Vito De Tullio zak.mc.kraken at libero.it
Sat Sep 20 07:03:01 EDT 2008


satoru wrote:

> hi, all
> i want to check if a variable is iterable like a list, how can i
> implement this?

untested

def is_iterable(param):
  try:
    iter(param)
  except TypeError:
    return False
  else:
    return True

-- 
By ZeD




More information about the Python-list mailing list