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, Se
satoru wrote:
On Sep 20, 6:35 pm, Aidan <[EMAIL PROTECTED]> wrote:
satoru wrote:
hi, all
i want to check if a variable is iterable like a list, how can i
implement this?
this would be one way, though I'm sure others exist:
if hasattr(yourVar, '__iter__'):
# do stuff
thank you,but th
thanks very much!
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 20, 8:54 pm, satoru <[EMAIL PROTECTED]> wrote:
> On Sep 20, 6:35 pm, Aidan <[EMAIL PROTECTED]> wrote:
>
> > satoru wrote:
> > > hi, all
> > > i want to check if a variable is iterable like a list, how can i
> > > implement this?
>
> > this would be one way, though I'm sure others exist:
>
>
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
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 20, 6:35 pm, Aidan <[EMAIL PROTECTED]> wrote:
> satoru wrote:
> > hi, all
> > i want to check if a variable is iterable like a list, how can i
> > implement this?
>
> this would be one way, though I'm sure others exist:
>
> if hasattr(yourVar, '__iter__'):
> # do stuff
thank you,but
satoru wrote:
hi, all
i want to check if a variable is iterable like a list, how can i
implement this?
this would be one way, though I'm sure others exist:
if hasattr(yourVar, '__iter__'):
# do stuff
--
http://mail.python.org/mailman/listinfo/python-list
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