is parameter an iterable?

lmaycotte at gmail.com lmaycotte at gmail.com
Tue Nov 15 23:06:17 CET 2005


Maybe this helps:

>>> import types
>>> def foo(inputVal):
      inValType = type(inputVal)
      if inValType==types.ListType or inValType==types.TupleType:
        for val in inputVal:
	  print val
      else:
	print 'Wrong input Type'


>>> list = [1,2,3,4]
>>> foo(list)
1
2
3
4
>>> tup = ('a', 'b', 'c')
>>> foo(tup)
a
b
c
>>> foo(9)
Wrong input Type
>>>




More information about the Python-list mailing list