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

James Mills prologic at shortcircuit.net.au
Sun Sep 21 18:26:57 EDT 2008


satoru,

I should point out that the normal
approach is to just try whatever it
is that you're doing, and let it fail
where it fails. For example:

def processSeq(x):
   for i in x:
      print i

processSeq([1, 2, 3])
processSeq("foobar")
processSeq(5) <-- This will fail.

cheers
James

On Sat, Sep 20, 2008 at 7:28 PM, satoru <torainLight at gmail.com> wrote:
> hi, all
> i want to check if a variable is iterable like a list, how can i
> implement this?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list